Add Local business schema just for one page not for all

#379876
  • Resolved Ross
    Rank Math free

    Hello,

    When I setup local SEO it adds localbusiness shema in all my pages and posts. How to add localbusiness schema only on those pages that I want?

    Thank!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    You can modify and use the filter on this page:
    https://rankmath.com/kb/remove-organization-schema/

    Hope that helps.

    Thank you.

    Ross
    Rank Math free

    Hello!

    Is there any way to add the schema just for a specific page not a homepage?

    Hello,

    You may need to edit this filter and add conditional statement on the post ID you wanted the Local Business schema like this:

    global $post;
    if( $post->ID == 558 || $post->ID == 558)
    {..

    Here is how you find the ID of your posts. Open the post that you want to find the ID for in a new tab, and check the URL. Here is an example.

    Post ID

    From the URL yourwebsite.com/wp-admin/post.php?post=27877&action=edit, extract the post= part. In this case, it would be:

    post=27877

    The number after the “=” sign is the post ID.

    I hope that helps.

    Thank you.

    Ross
    Rank Math free

    Thanks!

    Anas
    Rank Math business

    Hello,

    If you have any questions in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Ross
    Rank Math free

    As I can undertand I shoud combine all this code below. But I have no idea about how to write this code properly. Can you help me?

    global $post;
    if( $post->ID == 396 || $post->ID == 396)
    {..

    +

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 99, 2);

    +
    {"@type":"AggregateRating","ratingValue":4.6,"reviewCount":80}

    Thanks!!!

    Nigel
    Rank Math business

    Hello,

    To remove organization schema from all pages except the one with the specified ID the snippet will look like this:

    
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	global $post;
    	if ( $post->ID == 396 || ! isset( $data['publisher'] ) ) {
    		return $data;
    	}	unset( $data['publisher'] );
    	unset( $data['place'] );	return $data;
    }, 99, 2);
    

    Hope that helps. Please let us know if you have questions.

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

The ticket ‘Add Local business schema just for one page not for all’ is closed to new replies.