Need easy way to add head tags

Hi there, I'm trying to control the facebook image that appears from my customer's website when they create a FB post. Facebook says I need to add these HTML meta tags into page in the <head></head>. It will not work if you put it in the <body></body>. 

In other words, I need to add this:
<meta property="og:image" content="https://benfranklincraftswi.com/wp-content/uploads/2018/06/1-Facebook-Profile.jpg" />

In other themes, there is a simple head section to paste this code into place. I'm not a dev, so how can I easily add this code? If it involves PHP, please be specific, step by step. I've already read other support  topics on this and don't follow them exactly.

Site is https://benfranklincraftswi.com using X classic. All plugins, theme and core is updated.

Thanks!
Dawn

Hi There,

You don’t have to add the meta og:image tag. You can set the SOCIAL FALLBACK IMAGE under Theme Options > Social:

Hope it helps :slight_smile:

Hello Dawn,

Thanks for asking. :slight_smile:

You can add codes in head section using following solutions:

  1. Child theme way: Please add following code in your child theme function.php file.
add_action('wp_head','my_verification');
function my_verification () { ?>

<meta property="og:image" content="https://benfranklincraftswi.com/wp-content/uploads/2018/06/1-Facebook-Profile.jpg" />

<?php }

You can download child theme from following source.

https://theme.co/apex/child-themes

2.Plugin way: You can use Insert Headers and Footers plugin to add the code in header section. I am sharing the link to download and a guide to setup the plugin.

http://www.wpbeginner.com/plugins/how-to-add-header-and-footer-code-in-wordpress/

Hope that helps.

Thanks.

Neither of these options worked. Do you have other ideas?

Just an update - I’ve tried turning off the Open Graph on Yoast, enabling it on X and using the Social Fallback Image. Cleared the cache, and Facebook is still loading the wrong image.

Then I flipped it around and disabled Open Graph on X and uploaded the image to Yoast. Still nothing changed.

I’ve also tried using the “Insert Headers and Footers” plugin to paste the “Scripts in Header” box and that didn’t do anything. I also tried pasting it into the footer and that didn’t do anything either. The code I pasted was simply:

And lastly, I tried pasting the whole code from Prasant above into that same suggested plugin and that broke the site. Perhaps because the code is going into the header and not into php.

Does it take time for the open graph options to propagate? I wonder if clearing all caches and expecting this to work is too fast? Please help.

Thanks!
Dawn

Hi Dawn,

Yes, that’s correct. It takes time for it to propagate.

To be able to check, you can use facebook debug tools and click on scrape again.

https://developers.facebook.com/tools/debug

Also since you are using yoast, kindly remove the code in Headers and Footers plugin and disable X open graph. You can add all your og image Yoast instead.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.