Add area served schema inside a Service schema

#479325
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    To add the areaServed to the Service schema in the Rank Math free version, you may need to use and customize this sample filter on your site:

    add_filter( 'rank_math/snippet/rich_snippet_service_entity', function( $entity ) {
        $entity['service']['areaServed']['@type'] = 'GeoShape';    
        $entity['service']['areaServed']['sameAs'] = 'wiki.com/rankmath';
        return $entity;
    });

    And here’s a link to how to apply this to your site:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Hope that helps.

    Thank you.

    Hello, thanks for the answer!

    Thath code add the same area served in all service schema.

    Is there any snippet to add different area served schema on different service achemas?

    Thanks!

    (free version)

    Nigel
    Rank Math business

    Hello,

    Sorry, we do not have a premade snippet to add a different schema for each areaServed entity. The code snippet provided can be modified to give a unique areaServed schema for each location, but the amount of customization involved is beyond the scope of our support.

    Hope that answers you.

    I have also the same issue with my website, I used the above code as well that mentioned by Reinelle but it didn’t work for me. Please help

    Hello,

    I have 3 pages with 3 with service schema on it. How can I add a differnt area served schema for each service.

    (page 1)service 1: areaserved: Madrid
    (page 2) service 2: areaserved: Barcelona

    Thank!

    Hello,

    You can add the areaServed property based on the current URL. Here’s how you implement it via code:

    add_filter( 'rank_math/snippet/rich_snippet_service_entity', function( $entity ) {
    	$url = home_url( $_SERVER['REQUEST_URI'] );
    
    	if(strpos($url,"/madrid") !== false)  {
    		$entity['service']['areaServed']['@type'] = 'GeoShape';    
    		$entity['service']['areaServed']['sameAs'] = 'wiki.com/rankmath';
    	}
    	if(strpos($url,"/barcelona") !== false)  {
    		$entity['service']['areaServed']['@type'] = 'GeoShape';    
    		$entity['service']['areaServed']['sameAs'] = 'wiki.com/rankmath';
    	}
    	if(strpos($url,"/etc") !== false)  {
    		$entity['service']['areaServed']['@type'] = 'GeoShape';    
    		$entity['service']['areaServed']['sameAs'] = 'wiki.com/rankmath';
    	}
    
    	return $entity;
    });

    Hope that helps.

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

The ticket ‘Add area served schema inside a Service schema’ is closed to new replies.