Anyway you guys could add the ability to toggle
function hook_wp_head() {
if (is_single()) {
global $post;
// facebook sharing fix for videos, we add the custom meta data
if (has_post_thumbnail($post->ID)) {
$td_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ );
if (!empty($td_image[0])) {
echo ‘<meta property=”og:image” content=”‘ . $td_image[0] . ‘” />’;
}
}
on or off in the theme panel?
I haven’t been able to figure out how to child theme it out and every update I have to manually go in and just delete <meta property=”og:image” content=”‘ . $td_image[0] . ‘” /> manually.
I have tried using yoast but the above snippet always overrides what I set in yoast and as a result what gets shared via fb share button is the feature image instead of our customized fb image.
Hi Simion,
This issue is more serious than it seems at first. Facebook will use the first og:image tag that it encounters. Your functionality is overriding Yoast and therefore rending the wrong image for every post. In a previous post in 2018, someone from your team mentioned that you leave this functionality to other plugins, not sure why that has changed but it does more damage at this point than good.
Thanks.
Hi,
@Novanet The code referred to above is here – https://www.screencast.com/t/Iwl8siN49J
It outputs a meta image which may interfere with the sharing, when you use a different image for Facebook share in Yoast settings.
A quick fix would be to remove that code from the theme files until a solution is found in the matter on our side. Sorry again for the inconvenience.
Thanks