In my all post page there is share button (via AddThis plugin).
When I click to share on Facebook, it takes the URL and title, but images is showing something else. For example.
I tried to make a custom share button which is below, but when I click on it, nothing happens.
<?php
$title = the_title();
$url= the_permalink();
$summary=urlencode('Custom message that summarizes what your tab is about, or just a simple message to tell people to check out your tab.');
$image= wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image[0];?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Custom Share on Facebook page!
</a>
I have also put Open Graph tags in my header.php
between the <head>
tags:
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:description" content="" />
<meta property="og:image" content="<?php echo $image[0]; ?>" />
<meta property="og:video" content="" />
<meta property="og:video:width" content="560" />
<meta property="og:video:height" content="340" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
All my post from my website should be shareable on Facebook and Twitter with its URL, title, images, and description. Here's a working reference link.