-
Local Business Schema is somehow appearing in all posts.
How can I Remove Local Business Schema from posts?
-
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Can you please confirm if you want to use Local Business Schema only on your Homepage? If so, please use the following filter to remove Local Business Schema from all pages except Homepage:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { if ( is_front_page() || ! isset( $data['publisher'] ) ) { return $data; } unset( $data['publisher'] ); unset( $data['place'] ); return $data; }, 99, 2);
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps. Please don’t hesitate to let us know if you have any other questions.
Thank you.
Thank you so much for the support.
Well, I actually want to have the local business schema for the homepage and also for the contact page? is it possible?
Hello,
In that case, you can specify a specific page URL slug to avoid excluding it. You may refer to this filter code instead:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; if ( (is_front_page() || ! isset($data['publisher'])) || strpos($url, '/contact-us') ) { return $data; } unset( $data['publisher'] ); unset( $data['place'] ); return $data; }, 99, 2);
You may edit the
/contact-us
slug if that is not your contact us page and replace it with the correct slug.Let us know how that goes. Looking forward to helping you.
Thank you so much for the support.
can you please send me the code so that the local business schema appears on the Homepage, about and contact page?
so sorry to bother you. but i came to know , it is a good practice to have local business schema on only 3 pages, ie. homepage, about page and on contact page.
thank you again.
Hello,
Please use the following filter in order to use the Local Business Schema on the Homepage, about and contact page:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; if ( (is_front_page() || ! isset($data['publisher'])) || strpos($url, '/contact-us') || strpos($url, '/about-us') ) { return $data; } unset( $data['publisher'] ); unset( $data['place'] ); return $data; }, 99, 2);
Please edit the
/contact-us
and/about-us
slug with the correct slug of your contact us and about us page.Let us know how that goes.
Thank you.
It worked like a charm. Thank you alot for that.
Also, as i now have local business schema in home page, should i keep the article schema from rank math in tha home page, or should i remove the article schema for home page?
now i have 2 schemas for my home page, ie local business and Article.
Hello,
Glad that helped.
Yes, you can keep the Article schema as it tends to be the very basic structure to best describe the topic of a page, and it should be enough to describe the contents of your homepage.
When you mark up your posts and pages with Article Schema, they help search engines better understand the correct headline, published date & primary image of your article, and how they should be used in the search results.
Looking forward to helping 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.
The ticket ‘Local Business Schema is somehow appearing in all posts.’ is closed to new replies.