Reputation: 600
So I am trying to add a facebook and twitter share button for individual articles on my website. The articles are displayed using a php GET variable in the URL. The twitter and facebook share buttons are located on the home page which is different than the page which they are sharing (they are sharing the page of the article they are linked to). The code for the two buttons I have right now are
Twitter:
$url = rawurlencode("http://www.weGamblePro.com/article.php?article={$title}");
<a href='http://twitter.com/share?url=$url' class='twitter-share-button'>Tweet</a>
Facebook:
<div style='float: right;' class='fb-share-button'
data-href='http://www.weGamblePro.com/article.php?article=$title'
data-layout='button_count'>
</div>
My first problem is the twitter share button only shares the title of the home page and with no URL attached at all. I would like it to share the url of the article (i.e. just like how it is in the $url variable).
My second problem is with the facebook share, it shares the correct page, but I would like to be able to edit the description, title, and image that go along with it.
Advice on either of those two issues would be greatly appreciated.
Thanks.
Rendered example: www.weGamblePro.com
Upvotes: 1
Views: 1781
Reputation: 179994
Taking http://www.wegamblepro.com/article.php?article=Sports%20Betting%20Totals:%201989-2015 as an example:
Your <title>
tag is <title>weGamble | Article</title>
. That's what Facebook uses. Output $title
in the title tag and Facebook will use that.
You can control the title, description, image, etc. via Facebook's Open Graph markup, as documented here. From their example... <meta property="og:description" content="How much does culture influence creative thinking?" />
The Facebook debugger will tell you all of these things, and offer suggestions and a look at why Facebook is picking what it picks to display for your URL.
Upvotes: 1