Add specific schema for woocommerce product category

#442062
  • Resolved Denise Field
    Rank Math pro

    Hi

    We currently use Rank Math on our site – the free version. However, I want more specific schema for product categories.

    I will ned eventually schema for each different product category, so wanted to know if its possible to add JSON directly in the Rank Math section on the Product Category admin with the pro version.

    Unfortunately the way woocommerce is set up, there is only one template so its not possible to add this schema into the template file, while I can create custom pages, it would be much easier if this could be done using a plugin – ideally yours, because we are trying to limit the number of plugins on the site.

    Please can you let me know asap

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

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

    In the PRO version you can enable adding of custom schema by disabling the option “Remove Snippet Data” under Rank Math > Titles & Meta > Product: Product categories.

    This will reveal the schema tab in your product category editor. You can then import your custom json-ld code there.

    Hope that helps.

    Hi Jeremy

    I have now set up the Pro Version, but have 2 other issues.

    1. The product Category URL shows all the products on that page, under a product Schema see https://prnt.sc/3G8Q9iFG_E8o

    BUT, if I then add my custom Schema, the product dissapears and then the page groups up the custom schema. https://prnt.sc/vyY5SBXqm6hB

    I need to retain the original woocommerce generated product schema as well as keep all of the schema separate.

    2. I tried importing the JSON Script – as above – as a test to see if I could do that. When I go to the Import – Import from JSON-LD – when I cut and paste this code and press Process Code (with or without the script tags) nothing happens, what am I doing wrong?

    Hello,

    1. To get rid of the Product Schema on those pages and being able to add your own custom Schema you should use the following filter:

    
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if( is_product_category() ) {
            unset($data['ProductsPage']);
        }
        return $data;
    }, 99, 2);
    

    2. The import is failing because the JSON contains line breaks that are not parseable. You cannot have a line break in JSON without a preceding comma.

    Don’t hesitate to get in touch if you have any other questions.

    Hi

    Thank you for your reply, I don’t want to get rid of the original schema, I want to retain it and when I add additional schema using rank math, it is removing the original schema and further, if I add more than one schema its grouping them all together.

    Please look at the links I have provided, you can see what I mean.

    Thanks

    Denise

    Hello,

    Adding product schema to your category pages is not recommended as the schema should only be inserted on pages that refer to a single product according to Google guidelines:
    https://developers.google.com/search/docs/advanced/structured-data/product

    As for the JSON-ld, I went ahead and fixed the format for you. Please copy the json from here: https://pastebin.com/8abhCGez

    Let us know how that goes.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hi Jeremy

    Thank you, however it wasnt that exact schema I wanted uploaded, I have amended the sensitive data schema to the exact one, but I really cant see why Rank Math is having a problem in accepting it as I have cut and paste it, surely it doesnt need it formatted with all the line breaks in it??? Can you clarify, why its not accepting it the way I have cut/paste it.

    Also, I did cut and paste your amended json and it did accept it like that, however it was trying to add it to the existing webpage schema when I want it as a separate schema.

    Are you saying that you have designed Rank Math to add it to other schema types? And it will never create a separate schema for it?

    Thanks

    Denise

    Hello,

    Can you please point out which specific area of the screenshot you are having issues with?

    Rank Math sometimes generates the schema structure with other schema properties being nested or under Webpage. This is fine as long as the schema structure is validated in both schema.org and Google’s Rich Result Test.

    As for the format of the JSON you are trying to import, Rank Math follows the JSON standard so if there’s an unexpected line break, our plugin won’t process it.

    You may try checking your JSON code here and you should see that it also says invalid for line breaks: https://jsonlint.com/

    We are looking forward to helping you on this one.

    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 8 replies - 1 through 8 (of 8 total)

The ticket ‘Add specific schema for woocommerce product category’ is closed to new replies.