Basically, I am using facebook markup on my website.
If an article has more than one image the facebook markup doesn’t pick up the featured image for sharing, but does with only one image in the article.
I would like the facebook markup to pick up featured image no matter how many images are in the article?
Here is my markup:
<meta property="og:image" content="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID)); }?>" />
Does anyone know what needs changing?
Problem has been driving me nuts.
Regards
If you are not using any SEO plugin and want to do it in code, you might put this inside your
<head>
tags, probably inheader.php
of your themeWhere
large
selects the resized media size, you might want to play with the dimensions or even define custom media size to match facebook’s dimension recommendations.OG images can be tricky…
Make sure that there are no duplicate OG image tags, YOAST SEO also creates OG Image tags and some other SEO plugins might do the same.
I have seen that this confuses Facebook.
Just check your source code to see that the correct image is echoed in the OG tag.
Lastly use the Facebook debugger tool to see if you pick up any problems.