Hello,
Thank you for contacting Rank Math support today and bringing your concern to our attention.
As also mentioned in your other ticket, you need to further extend your schema structure by customizing our filter code here: https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data
After you customize the filter code to edit your schema structure, you may apply the code to your themeās functions.php file.
Hope this helps you with your situation. Looking forward to helping you on this one.
Thank you.
Hello again, how can I add this code in that custom php filter?:
"areaServed": [{
"@type": "City",
"name": "Madrid",
"sameAs": "https://en.wikipedia.org/wiki/Madrid"
}]
Thanks!!!
Hello,
You can use the filter given below to add the areaServed to the Organization Schema:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['publisher'] ) ) {
$data['publisher']['areaServed']['@type'] = "city";
$data['publisher']['areaServed']['name'] = "Madrid";
$data['publisher']['areaServed']['sameAs'] = "https://en.wikipedia.org/wiki/Madrid";
}
return $data;
}, 99, 2 );
Hope this helps. Let us know if you need any other assistance.
Thanks.
Hello,
We are super happy that this resolved your issue.
If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.