How to change language in schema markup for category

#308737
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    You can edit the following filter to your specifications to achieve a similar result:

    
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if( in_category( 1 ) ) { // Change this to the category ID that you want to change
            $data['WebSite']['inLanguage'] = 'de-DE';
            $data['WebPage']['inLanguage'] = 'de-DE';
        }
        return $data;
    }, 99, 2);
    

    Hope this helps solve your issues.
    ​​​​​​​
    Don’t hesitate to get in touch if you have any other questions.

    Evanne
    Rank Math free

    Hello Miguel,

    thanks for your answer, I got the same issue with the “Organization” markup. What is your recommandation on that in order to change it for another country tag?

    "inLanguage": "en-US",

    Have a nice day

    Thank you for your answer. I solved the problem by adding class-jsonld.php to this

        private function add_prop_language( &$entity ) {
        if (in_category( ‘choosen-category’ ) ) {
        $entity[‘inLanguage’] = ‘en-us’;
        }
        else {
        $entity[‘inLanguage’] = $this->do_filter( ‘schema/language’, get_bloginfo( ‘language’ ) );
        }
        }

    Azib Yaqoob
    Rank Math business

    Hello,

    Glad that helped and thank you for sharing the code.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘How to change language in schema markup for category’ is closed to new replies.