How to Add Facebook Open Graph Meta Data in WordPress Themes

We shared with you the way to upload the fb like button in WordPress. Then we wrote about how to upload the fb ship button in WordPress. Now most often, Facebook is actually good in pulling in the proper information to your posts when they’re shared on Facebook. However not too long ago, we’ve been listening to experiences of Facebook now not pulling the proper thumbnail symbol when somebody clicks Like, now not pulling the proper web page identify, and many others. Well in this text, we will be able to percentage how you’ll be able to upload fb open graph meta knowledge in WordPress subject matters which can remedy all of the ones problems.

We have 3 strategies for you, two of them require you to set up a plugin. The 3rd way is for intermediate stage customers who don’t seem to be shy of enhancing their subject matters.

Adding Facebook Open Graph Meta Data with WordPress search engine optimization

At WPBeginner, and on all our internet sites we use WordPress search engine optimization. It now not handiest is helping you upload titles and meta descriptions. It is your entire web site optimization bundle for WordPress. WordPress search engine optimization additionally comes provided with social options, together with the facility to upload Facebook Open Graph meta information in WordPress subject matters.

First factor you wish to have to do is set up and turn on, the WordPress search engine optimization via Yoast plugin. Once activated, you wish to have to move to search engine optimization » Social and easily take a look at the field subsequent toAdd Open Graph meta information.

Enable Facebook Open Graph meta data

You can save your settings or proceed and configure different Facebook social choices at the display. You can attach your web site to your Facebook consumer account because the admin. Doing so it is possible for you to to see Facebook insights for this web site. You too can supply your Facebook web page’s URL and it’ll be added into Facebook Open Graph meta information.

On the similar web page, you’ll be able to upload a picture and outline to your entrance web page. You too can upload a default symbol to be used when an editorial does now not have any symbol hooked up to it.

That’s all, you will have effectively added Facebook open graph meta information into your WordPress theme.

Adding Open Graph Meta Data in WordPress Using Official Facebook Plugin

If you might be the usage of every other search engine optimization plugin like All in One search engine optimization, or just don’t need to set up WordPress search engine optimization plugin, then you’ll be able to nonetheless upload Facebook open graph meta information the usage of the professional Facebook plugin for WordPress.

First factor you wish to have to do is set up and turn on the Facebook plugin. Simply activating the Facebook plugin will upload open graph meta deta into your theme’s header.

That’s all you will have enabled Facebook open graph meta information for your WordPress web site.

Using the professional Facebook plugin lets in you to use many different options this powerful plugin provides. For instance, you’ll be able to use it to upload a Facebook Likebox / Fanbox, embed Facebook standing posts, upload observe button for authors, and a lot more.

Manually Add Facebook Open Graph Meta Data into Your WordPress Theme

This way calls for you to edit your theme information, so just remember to backup your theme information ahead of making any adjustments. Simply replica and paste this code in your theme’s purposes.php record or a site-specific plugin.

//Adding the Open Graph in the Language Attributes
serve as add_opengraph_doctype( $output ) {
		go back $output . ' xmlns:og="" xmlns:facebook=""';
add_filter('language_attributes', 'add_opengraph_doctype');

//Lets upload Open Graph Meta Info

serve as insert_fb_in_head() {
	world $put up;
	if ( !is_singular()) //if it's not a put up or a web page
		go back;
        echo '<meta assets="facebook:admins" content material="YOUR USER ID"/>';
        echo '<meta assets="og:identify" content material="' . get_the_title() . '"/>';
        echo '<meta assets="og:sort" content material="article"/>';
        echo '<meta assets="og:url" content material="' . get_permalink() . '"/>';
        echo '<meta assets="og:site_name" content material="Your Site NAME Goes HERE"/>';
	if(!has_post_thumbnail( $post->ID )) { //the put up does now not have featured symbol, use a default symbol
		$default_image=""; //exchange this with a default symbol for your server or a picture in your media library
		echo '<meta assets="og:symbol" content material="' . $default_image . '"/>';
		$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
		echo '<meta assets="og:symbol" content material="' . esc_attr( $thumbnail_src[0] ) . '"/>';
	echo "
add_action( 'wp_head', 'insert_fb_in_head', 5 );

Note: Remember to trade the Site Name the place it says “Your Site Name Goes Here”. Also trade the default symbol URL with the picture of yours. We would suggest placing a picture along with your brand there, so in case your put up does now not have a thumbnail, then it pulls your web site’s brand. Studies display that posts shared and not using a thumbnail are much less efficient than the ones with thumbnails. Also don’t omit to upload your USER ID. You can to find your Facebook consumer ID via going to this URL: (Just exchange syedbalkhi with your individual username).

That’s all you wish to have to do. As quickly as you save your purposes.php record (or site-specific plugin) it’ll get started appearing Facebook open graph meta information in WordPress header.

We hope this text helped you upload Facebook open graph meta information in WordPress. Its an effective way to get customers engaged along with your content material on Facebook’s large social platform.

If you really liked this text, then please subscribe to our YouTube Channel for extra WordPress video tutorials. You too can to find us on Twitter and Facebook.

Recent Articles

The New Apple Music Features to Definitely Try in 2021

Apple Music is a nice app but it is not the most loved app, even among Apple users. The wide range of...

Best Free News Apps for iPhone and iPad in 2021

The year isn’t going as we expected, we are still living through a pandemic and all the problems of the world didn’t...

Best Apps to Hide Pictures & Videos on Your Phone

Privacy is important in everyone’s life, the intensity might change but no one wants to share everything with the world. Even the...

5 Best Health Apps for a Healthy Lifestyle for Everyone in 2021

Times have changed, but the only thing that has remained constant is the need for a healthy lifestyle. Various factors contribute to...

The Most Exciting Features of Apple iOS 14.5 for iPhone and iPad

The Most Exciting Features of Apple iOS 14.5  Apple tries to bring something new and better with every iOS...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here