For example, the code below removes the organization schema from all pages except the home page.
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);
I need code to delete organization, website, web page schema from all pages.
In fact, I want to cancel all automatic schema coming to the pages. I want to add them one by one. Is there a code for this?
Hello,
Thank you for contacting the support.
Please use the filter given below to remove the default Schemas added by our plugin:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
unset($data['publisher']);
unset($data['WebSite']);
unset($data['WebPage']);
return $data;
}, 99, 2);
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope this helps. Let us know if you need any other assistance.
Thank you so much. The code is working. It worked great for me.
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do 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.