How to change Open Graph at a page level?

#12088
  • Resolved Jane Freeman
    Rank Math free

    Hi

    I have created a international subfolder on a USA based site, but have this on my international pages:

    <meta property=”og:locale” content=”en_US”>

    How to I change this at a page/sub folder level ?????

    Thanks

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can add the following code on your theme’s functions.php file and then modify it further as described on the comments:

    /**
     * Change Rank Math OG tags
     *
     * The dynamic part of the hook name. $network, is the network slug
     * and $og_property, is the property which we are outputting.
     *
     * @param string $content The content of the property.
     */
    add_filter( "rank_math/opengraph/facebook/og_locale", function( $content ) {
    	//replace /custompagename/ with the path to the page you want to 
    	//modify the tags
    	if($_SERVER['REQUEST_URI']=="/custompagename/"){
    		//replace en_UK with your preferred locale
    	$content = "en_UK";
    	return $content;
    	}
    	return $content;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘How to change Open Graph at a page level?’ is closed to new replies.