On a wordpress site, I'm using sharethis plugin...
http://support.sharethis.com/customer/portal/articles/446440-wordpress-integration
Where FB Share Link Button doesn't fetch and display Post description & image on facebook.
Any idea/hint what could be wrong?
Please add this function into your functions.php file.
function wpc_fb_opengraph() {
$wpc_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
?>
<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
<meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
<meta property="fb:app_id" content="APP ID HERE">
<meta property="fb:admins" content="YOUR FB USER ID (OR USERNAME) HERE"/>
<meta property="og:image" content="<?php echo $wpc_image_url[0] ?>"/>
<?php }
add_action('wp_head', 'wpc_fb_opengraph');
Note : if you haven't yet any facebook app for your web pages you dont have to use this lines .
<meta property="fb:app_id" content="APP ID HERE">
<meta property="fb:admins" content="YOUR FB USER ID (OR USERNAME) HERE"/>
Happy Wordpress..
You might want to try implemented the Open Graph Meta Tags if you haven't - the will give Facebook's servers hints as to what content you want to display if it can't be parsed automatically.
Info here: http://davidwalsh.name/facebook-meta-tags
Related
I have my meta tags working until I changed it to be appeared only when a certain page is loaded.
This is my code:
<title>
Effro | <?php echo isset($metatitle) ? $metatitle : 'Homepage'; ?>
</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--Facebook og -->
<meta property="fb:app_id" content="1247181518629773" />
<?php
if(isset($is_ref) && $is_ref):
?>
<meta property="og:type" content="website" />
<meta property="og:title" content="Effro - We Solve Your Ambitious Event" />
<meta property="og:description" content="This i s a test Description" />
<meta property="og:image" content="<?php echo base_url().'assets/img/Effro_Facebook_Share.jpg'; ?>" />
<meta property="og:url" content="<?php echo site_url().'talents/referral'; ?>" />
<?php
endif;
?>
I tried Open Graph Object Debugger several times. But it is not picking up the values.
I have this website with dynamic pages. Now there's a page with an overview of all articles and a page with detailed view that shows the complete article when you click it's title on the overview page. The URL of the detail page is something like this for example:
http://www.mysite.com/view.php?ID=43
Now i want to implement the facebook like button that only shows on the detailed page on the bottom of each article. I've found out that i have to use the Open Graph meta tags like below
<meta property="og:title" content="My title" />
<meta property="og:type" content="article" />
<meta property="og:url" content="My url" />
<meta property="og:image" content="my img" />
<meta property="og:site_name" content="My site name" />
<meta property="fb:admins" content="admin number" />
Now my question is, how do i dynamically fill in the content values of each meta property? So that each article has it's 'own' like button. Is there a way to print php statements inside or something?
Yes you can dynamically fill these values the same way you would dynamically fill any parameter or element in your HTML.
<meta property="og:title" content="<?php print $title; ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="myurl/<?php print $articleurl; ?>" />
<meta property="og:image" content="<?php print $article_image; ?>" />
<meta property="og:site_name" content="My site name" />
<meta property="fb:admins" content="admin number" />
Don't forget to use http://developers.facebook.com/tools/debug to check your OGP tags are being interpreted as you desire. Facebook is very strict with it's expectations to follow protocol.
I'm having a problem that I can't seem to figure out, though I'm not sure if I'm on the right track. Can anyone please advise?
I've just created a wordpress website, that post's will be shared on facebook.
I'm using featured images and I would like my featured image facebook thumbnail to be used.
It seems when I post a link to facebook, facebook just picks up images on the page and you can choose a thumbnail.
I'm not really up for that because the images are landscape and don't look good. So I started looking into meta tag with the open graph property to see if I could dynamically populate the content that facebook captures when posting a link to the wall.
This is what I tried...
<meta name="description" content="" />
<meta name="author" content="" />
<meta charset="utf-8" />
<meta property="fb:app_id" content="0000000000000000" />
<?php if ( is_single() || is_page() ) { ?>
<meta property="og:title" content="<?php echo get_the_title(); ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo get_permalink(); ?>" />
<meta property="og:image" content="<?php $fbthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'facebook-thumb' ); echo $fbthumb[0]; ?>" />
<meta property="og:site_name" content="myblog.co.uk"/>
<meta property="og:description" content="<?php echo get_the_excerpt(); ?>" />
<?php } ?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
But all of this is ignored!!!
Can anyone help me understand how to control the content facebook draws in via a link being posted to a wall. I would appreciated your help very much.
Thanks
I had this problem the other day. Facebook wants og:images to be larger than 200px in both directions, or it will ignore them. I found I got the best result when I used wp_get_attachment_image_src($img.ID, 'large')
Have you tried looking at your site with the Facebook Debugger to see what it has to say about your site? https://developers.facebook.com/tools/debug
We run a blog in the UK and have recently noticed that Facebook stopped pulling our post descriptions and images when an article is liked, shared etc.
Running the Facebook Object Debugger I get the following messages:
Response Code: 200
Errors That Must Be Fixed
Can't Download: Could not retrieve data from URL.
(In case you wish to see it for yourself, here is a link: https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.heruni.com%2F)
Below is a copy of our code -- what are we doing wrong?
<?php
function is_facebook(){
if(!(stristr($_SERVER["HTTP_USER_AGENT"],'facebook') === FALSE)) {
return true;
}
}
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"<?php if(is_facebook()){echo ' xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"';}?>>
<head>
<title><?php wp_title(''); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="msvalidate.01" content="374D59D3C3F26F6EFC410429D512A98C" />
<?php if(is_facebook()){ ?>
<meta property="og:title" content="<?php single_post_title(''); ?>"/>
<meta property="og:type" content="article"/>
<meta property="og:image" content="<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ) ?>"/>
<meta property="og:url" content="http://<?php echo $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];?>"/>
<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>
<meta property="fb:app_id" content="256997234347344"/>
<?php }?>
Check if you use gzip in your page, disable it and try again. That fixed it for me.
This is the markup which Facebook sees for your page:
https://developers.facebook.com/tools/debug/og/echo?q=http%3A%2F%2Fwww.heruni.com%2F
You don't need to do any is_facebook() conditional stuff here - the tags, and the namespace should just be made visible on the web to all HTTP clients, not just the Facebook scraper.
Remove all these conditionals, and you code should work.
I am trying to share a link using sharer.php on facebook.I have used the code
<a style="cursor: pointer;" target="_blank" title="
<?php echo ucfirst($this->headline); ?>"
href="http://www.facebook.com/sharer.php?u=<?php echo $url ?>" >
$url is urlencoded here.
i have used the og meta tags as follows:
<meta property="og:title" content="Test" />
<meta property="og:type" content="company" />
<meta property="og:url" content="http://75.125.190.162:7113/index.php?option=com_realtyna&view=propertyshow&building_name=&category=FLAT&country=&state=Ariana&city=Ariana+Ville&zone=&listing_type=&bedroom=Three+bedrooms&pid=180&Itemid=3&lang=en" />
<meta property="og:image" content="http://75.125.190.162:7113/components/com_realtyna/uploads/180/180_main_iHq29q.jpg" />
<meta property="og:site_name" content="Test" />
<meta property="fb:admins" content="100000626812232" />
The problem is that on sharing it on facebook it doesnt shows the title which i specified here.It seems to pick the title of the page but changing it also doesnt helps.I cant figure out from where it is picking up the title.
Help Anyone.
Url to the page is :
http://75.125.190.162:7113/index.php?option=com_realtyna&view=propertyshow&building_name=&category=FLAT&country=&state=Ariana&city=Ariana+Ville&zone=&listing_type=&bedroom=Three+bedrooms&pid=180&Itemid=3&lang=en
Just put multiple og:image tags and it will give the user an option to choose which photo they want to use.
<meta property="og:image" content="http://75.125.190.162:7113/components/com_realtyna/uploads/180/180_main_iHq29q.jpg" />
<meta property="og:image" content="http://75.125.190.162:7113/components/com_realtyna/uploads/180/180_main_47Lcge.jpg" />
Source: https://developers.facebook.com/docs/opengraph/