Add Facebook Open Graph Tags To WordPress

 In Media, Social Network

When a link is shared on Facebook it will be crawled to get the page title and description. The wayFacebook will get this information is to search for Open Graph tags, these are meta tags added to your page with a title, description and image data. This data is then used to populate the Facebook status box when someone shares your link.

Add the following to your head tag so that Facebook will understand the content you are posting.

Page Title

To tell Facebook what the title of the page is you need to use the meta tag og:title, this will appear at the top of the post on Facebook.


Page Type

As you can post lots of different type of content to Facebook includes, articles, activities, businesses, groups, people, places..etc you can use the type meta tag to tell Facebook what type of content this is.

List Of Content Types

Post Image

You can set an image to use as the post image on Facebook by using the image meta tag.


Post URL

To set the URL for the shared link. This will be the link that will be placed on Facebook when your content is shared.


Post Description
Along with a default title and image you can set a small description of the content.



Site Name
Provide Facebook with your website name which can be referenced in your post on Facebook.

Wordpress doesn’t come with the functionality to add Facebook open graph meta tags, but you can use the below snippet to add open graph meta tags to all your posts. Simply add the following code to your functions.php page and it will automatically create the Facebook open graph tags for you, so no need to have the Facebook plugins on your WordPress site.



Open Graph Tester Tool

Once the above code is on your website and you would like to test the contents of your website without sharing it on Facebook then you can use the following tool to check a web page and make sure that the open graph data is correct.


Test your URL with Facebook url debugger .here

You may be also interested in display custom content to your search-engines @ – Nuno Sarmento


Nuno Sarmento
I am full-stack WordPress developer based in London with a wealth of theme development and support experience. I am great at problem solving and developing quick solutions. I specialise in custom WordPress theme development and bug fixing.
Recommended Posts

Leave a Comment

Start typing and press Enter to search