Need in adding Hook to my website

#61682
  • Resolved Zack Micheal
    Rank Math free

    we would like to add schema like this in our website but don’t know to use filters hooks of rankmath? I try to add it with code snippet plugin in wordpress. If I add following code to function file it will give new field to add schema in each page?

    /**
     * Collect data to output in JSON-LD.
     *
     * @param array  $unsigned An array of data to output in json-ld.
     * @param JsonLD $unsigned JsonLD instance.
     */
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 10, 2);

    `”areaServed”: [{
    “@type”: “City”,
    “name”: “Boulder”,
    “sameAs”: “https://en.wikipedia.org/wiki/Boulder,_Colorado”
    },
    {
    “@type”: “City”,
    “name”: “Denver”,
    “sameAs”: “https://en.wikipedia.org/wiki/Denver”
    }]
    }`

Viewing 5 replies - 1 through 5 (of 5 total)
  • Todd
    Rank Math free

    Hi Miachel,

    Here is an example code you can try:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if ( isset( $data['Organization'] ) ) {
            $data['Organization']['sameAs'] = ['https://twitter.com/RankMath', 'https://facebook.com/....'];
        }
        return $data;
    }, 99, 2 );

    Please edit as per your requirements.

    but we want to add separate code for each page. like different service location.

    Todd
    Rank Math free

    Then,

    You should use this instead of the filters to make it easier:
    https://technicalseo.com/tools/schema-markup-generator/

    Grab the code and place it inside the page’s source code:

    Hope that helps.

    ok we need to do it manually.

    Hello,

    Thank you for contacting Rank Math today.

    Unfortunately to add it differently for each page, you will have to do it manually on each of your pages.

    Please do not hesitate to let us know if you need our assistance with anything else.

    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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Need in adding Hook to my website’ is closed to new replies.