the_post_thumbnail() as og:image infamous bug ;-)
-
Hi !
(By the way I tested that by disabling all plugins and with Twentyseventeen on, and the same issue appears)
I have a Q&A website and activated thumbnails in my template so that it shows a 150x150px featured image for every question (Questions are a custom post type), with the following code :
<?php the_post_thumbnail(); ?>.
And it works, images appear within the content of the question.But if I had the following code in header.php, in <head> :
<meta property=”og:image” content=”<?php the_post_thumbnail(); ?>” />
or
<meta property=”og:image” content=”<?php the_post_thumbnail(large); ?>” />Facebook debugging tool says “Non-valid URL : the URL of the element og:image was not specified”. And indeed, in the sourcecode, there is <meta property=”og:image” content=”” />, which means the url of the og:image is empty.
Now this is the exact same code in both cases, except that when it is in the <body> it gets interpreted, when it’s in the <head> nothing happens.
Any idea why ?
Thanks for your time ! ??
- The topic ‘the_post_thumbnail() as og:image infamous bug ;-)’ is closed to new replies.