Hello,
We apologize for the issue you are facing with the code to remove products from the shop page. The code you provided is attempting to unset the ‘Product’ schema, but it may not be structured correctly for your needs.
To remove all Schema from product category pages, you can use the following alternative code snippet:
/**
* Filter to remove all Schema from product category pages
*/
add_filter('rank_math/json_ld', function ($data, $jsonld) {
if (is_shop()) {
return [];
}
return $data;
}, 99, 2);
This code will effectively remove all Schema data from the shop page. Make sure to add this code to your rank-math.php file as you did before.
If you have any further questions or need additional assistance, please feel free to reply to this ticket, and a human agent from our support team will be happy to help you further. Thank you for raising this concern!
Sources:
Remove All Schema from Product Category Pages » Rank Math
This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.
I would prefer to keep the other snippets as they are useful collection snippets.
How can I remove only the product data.
Everything I have tries does not work.
Hello,
Thank you so much for getting in touch.
Please try this instead:
add_filter('rank_math/json_ld', function ($data, $jsonld) {
foreach ($data as $key => $schema) {
if( (is_front_page() || is_shop()) && 'Product' === $schema['@type'] ) {
unset( $data[ $key ] );
}
}
return $data;
}, 99, 2);
You can also try this code:
add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
if( is_front_page() || is_shop() ) {
return false;
}
return $entity;
});
Let us know how that goes. Looking forward to helping you.