All Collections
Developer Resources
Filter Open Graph Social Meta Data
Filter Open Graph Social Meta Data

Learn more about the Social Meta Data filter.

Thrive Themes avatar
Written by Thrive Themes
Updated over a week ago

We recently had an issue where a customer converted to https but wanted to retain non https open graph social metadata.

To enable this, we've added a filter that allows you to modify the open graph metadata programmatically.

The New Filter:

We've added this filter to our codebase on all themes:

$meta = apply_filters('tha_social_meta', $meta);

$meta is an array of metadata as constructed as follows:-

$meta = array(
//uniqueID => meta
'og:type' => array(
//attribute -> value
'property' => 'og:type',
'content' => $page_type,
'og:url' => array(
'property' => 'og:url',
'content' => $current_url,),
'twitter:card' => array(
'name' => 'twitter:card',
'content' => 'summary_large_image'

Example of How to Filter the Open Graph MetaData:

If you're running a child theme you can add the following code in functions.php. Alternatively, if you're not running a child theme, then we recommend you create this as a separate plugin so your changes aren't overwritten on theme update.

Sample Code for this Filter

This example overrides the og:url meta:

add_filter("tha_social_meta", "modify_og_url");
function modify_og_url($meta) {
$url = 'your custom url';
$meta['og:url']['content'] = $url;
return $meta;

This filter will allow you to do things like:

  • Modify the social meta protocol to retain previously built social meta signals

  • Make any other changes that you require to the social metadata parameters

Did this answer your question?