WordPress: How to Fix No featured thumbnail issue on facebook share

Yesterday I’ve noticed that when I share my post to my Facebook fanpage, my feature image were not showing, I’ll try to find answer by searching Google but I couldn’t find perfect solution to fix the problem, and I’m sure if you are reading my post you are also on my situation before. I’ve search google for keywords that Facebook debugger giving like improper use of OG image metatags but it always shows result with same problem and no solution.

For almost 2 to 3 hours yesterday I’ve been searching for solution, I follow some instructions that I read to some forum that I found while searching for answers, like removing all the plugins related to facebook and activate it one by one to find out what plugins causing the conflict but I  couldn’t make it to work. But I found a perfect solution to my problem that I think it might also solve yours, I decided to write this post to share and help.

This post will show the simple steps that you are looking to fix no featured thumbnail issue on facebook share, I’ve got the solution from wpbeginner.com and I’m thankful for them for making that simple yet perfect solution to the problem.

Follow this simple steps to fixed your no featured thumbnail problem, by the way this solution is for WordPress users only.

Open up your functions.php file and paste the code inside the php tags, be sure to put the code inside the closing of php tag or else you know the results.

function insert_image_src_rel_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
$default_image="http://example.com/image.jpg"; //replace this with a default image on your server or an image in your media library
echo '<meta property="og:image" content="' . $default_image . '"/>';
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
echo "
add_action( 'wp_head', 'insert_image_src_rel_in_head', 5 );

Please consider sharing if you find it helpful, credits to wpbeginner.com :)


Get our latest updates directly to your inbox! Subscribe to our mailing list or Like/Follow our Social Media account.