Pergunta

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?

Foi útil?

Solução

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..

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top