Hello,
Thank you for contacting Rank Math today.
Yes this is possible, you can add the following code to your theme’s functions.php file to disable product rich snippets site wide:
/**
* Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
* Replace $schmea_type with schema name like article, review, etc.
* @param bool $value true/false Default false
* @param array $parts Post Data
* @param array $data Schmea Data
*
* @return bool
*/
add_filter( "rank_math/snippet/rich_snippet_product", function( $value, $parts, $data ) {
return true;
}, 10, 3 );
I can however recommend that you fix the structured data errors by following these steps:
Please acquire some reviews and ratings to get rid of the aggregateRating
and review
warnings.
You can fix the SKU and availability issue easily as well:
You can fix the ‘offers’ error by assigning a sales price to your products as shown below:
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thanks for the detailed reply.
The problem is that I only want to disable this feature for a specific category of products because that set of products are not available for direct purchase, they’re just displayed as a price list.
Hi Maxwel,
Thanks for getting back to us.
In this case, you can replace the previous code with the following:
add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
global $post;
//Replace 'category_name' with your category slug
if ( has_term( 'category_name', 'product_cat', $post->ID ) ) {
return false;
}
return $entity;
});
I hope this info helps. Thank you.
Great, thanks very much 🙂
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/?rate=5#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.