Configuring WordPress for OpenGraph On Social Media

black iphone 4 on brown wooden table

Have you ever noticed when you post a link on Facebook or LinkedIn that it will pull in a title, description and image? This is called OpenGraph tagging and can be used to present information in a more visually appealing manner. However, if it’s not set up correctly, it can cause your social media post to look a bit strange.

Below are tips to get your featured images to show correctly in social media posts.

Get A WordPress SEO Plugin First

Because OpenGraph uses a special type of meta-tagging to display a title, description and image, an SEO plugin will help with the coding aspect of this content. Consider tools like Rankmath or Yoast SEO; these two options are configured to work with WordPress and override certain files. Web developer Jeff Romero says, “With these types of plugins, the OpenGraph tag is rendered in the header.php along with other meta tags via the plugin and all you have to do is provide the details.” With the right plugin, you’re on your way to creating content for these fields.

What To Do In WordPress

When publishing a page or post, you’ll need to set a featured image. This featured image is what is selected when the page or post is shared on social media. Depending on the plugin you use, you may or may not have fields for the title and description fields, but you will use the featured image field for the OpenGraph image.

Use the Right Size Dimensions for Your Images

Unfortunately, every social media outlet has different post sizes. For instance, a post on Facebook will be less wide compared to LinkedIn and Twitter will require a thin timeline image. Because of these size differences, it’s important to create images that are flexible for all platforms. Avoid designs where the text or image content hugs the edge of the content, but has plenty of white space to use. This will give larger margins and be more compatible with different social media sites. Once you create a few images, you’ll begin to see what works best.

Previewing the Posts On Social Media Channels

Each major social media platform has a preview tool that will read your page’s HTML and output a preview of what the post will look like. Occasionally, the testing tools will not be able to pick up the OpenGraph HTML from your pages. Test it again and if it still doesn’t retrieve the content, check your site for any issues. It’s possible the post isn’t published yet from WordPress or it could be password protected.

You May Need to Clear the Cache

If your website is using caching plugins to improve its sitespeed, there’s a chance the plugins are not allowing social media sites to access the most recent version of your content. You may have made changes to your post title, post description or post image, but the testing tool is showing something different. Be sure to clear your site cache if you run into this issue. Additionally, you may need to clear the cached version from the social media site you are posting to. Each testing tool allows you to clear the cache of the post you’re working on. This will make Facebook, Twitter or LinkedIn refresh the page with your most recent content. If you are still seeing cached content after taking these steps, be sure to check your site for any other caching issues.

Once You Have Posted

Once you publish your post on your target social media channel, it will continue to display the post title, post description and post image. Even if you choose to delete content down the road, just now that the social media website will show it as when it was published.

Good luck with OpenGraph tagging and let us know if we can help solve any trouble you’re having.