Bulk Disable Rich Snippets for Products?

#14781
  • Resolved Maxwell Hibbert
    Rank Math free

    Is it possible to bulk disable rich snippets for existing products?

    We’ve got a large number of products in a specific category that we use in a pricelist only format. But we’re getting warnings from Google about the rich snippets for these:

    Either “offers”, “review”, or “aggregateRating” should be specified.

    We also don’t want the links to the usual product page for these products to be public.

    The switch in the settings that disables the rich snippets on products seems to only cover “new products”..

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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:
    Offers

    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.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Bulk Disable Rich Snippets for Products?’ is closed to new replies.