Product Variations – only send default product to GSC

#5601
  • Resolved Paul
    Rank Math free

    Hi,

    I have a number of Variable Products in Woocommerce, where a single product could have a large number of variations due to size, colour etc.

    Right now Rank Math rich snippets for products is allowing all the product variants to be picked up by Google search console.

    It also looks like the main Rank Math snipet ‘description’ is ignored when you have variants. It shows an empty description for the product and is looking for a description for each variant in the GSC.

    I have set a default variant for most products and I want to only send information for that default variant to google search console including the rich snippet data.

    Is there a way to achieve this in Rank Math as I could do it in Yoast?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    This is also possible in Rank Math, you can make use of the following filter to modify the schema data produced for added to the page for products:

    /**
     * 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 array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema_type}", function( $entity ) {
    	return $entity;
    });

    I hope this info helps. Thank you.

    ​​​​​​​

    Paul
    Rank Math free

    Hi Michael,

    That filter doesn’t address any of the issues raised in the ticket.

    It will just call the product schema which is already being called and the problems still exist.

    Todd
    Rank Math free

    Hi Paul,

    You can use this filter to extend the schema:

    https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data

    /**
     * Collect data to output in JSON-LD.
     *
     * @param array  $unsigned An array of data to output in json-ld.
     * @param JsonLD $unsigned JsonLD instance.
     */
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 10, 2);

    In the meantime, we will also see if there is a way to handle this in a better way.

    Appreciate your patience in this matter.

    Paul
    Rank Math free

    Hi Todd,

    Thanks for the filter. Can you let me know what the expected outcome of adding that filter is please. Do I need to do anything else after adding it?

    I put it in my functions.php but can’t see any change in GSC.

    Cheers,

    Paul

    Hi Paul,

    Thanks for the question.

    You need to pass a custom array containing the json-ld data that you want to be added to the existing schema on the page.

    Please take a look at the following page for more info on the available arguments that you can use https://schema.org/Product

    I hope this info helps. Thank 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.

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

The ticket ‘Product Variations – only send default product to GSC’ is closed to new replies.