how to remove all unwanted categories in woocommerce archive pages.

#66127
  • Resolved IMAGE BURST
    Rank Math free

    Hi,

    I’ve made a xml file to include only certain categories and pages, posts as well as categories in woocommerce, but google doesn’t just consume only the sitempa I’ve given it, it also still has other archive pages that I don’t want appear in the search results regarding my site. There are over 30+ categories like, eanlist, ups, sku, weight, color, etc… that are showing up as categories in the search results. Is there a snippet to ignore all eanlist/*, upc/*, sku/* and not index? I know I can manually index it but it would take way to long as there’s too many archive categories. What can I do in this case?

    Thanks,

    Tony

    • This topic was modified 4 years, 2 months ago by IMAGE BURST.
Viewing 15 replies - 1 through 15 (of 18 total)
  • Alberto
    Rank Math business

    Hello,

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

    I am not sure if I understand it as you wanted, but I think you want to not index some categories and it is not working for you. Could you go to each one of them and set them as no-index or what you were saying before is that they are too many to do it manually?

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Yes, that’s what I mean. Sorry couldn’t explain it better. There is too many to manually perform that action.

    Hello,

    Unfortunately we currently have the bulk noindex option. You can try and customize the following filter to help your issue.

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $post;
         // filter for only a specific post type
         if(get_category() == "your category array/list"){
            $robots['index'] = "noindex";
            return $robots;
         }
    	return $robots;
    });
    

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you for that helpful info, I’m assuming I need to add this to my function.php in my child theme. Also just to make sure, see the example I’ve added with your provided sample code.

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $post;
         // filter for only a specific post type
         if(get_category() == "ean, model, eanlist, upc, partnumber, upclist, studio, manufacturer, mpn, label, home-base, producttypename, size, productgroup, warranty, packagequantity, item-model-number, catalognumberlist, publisher, product partnumber, size array/list"){
            $robots['index'] = "noindex";
            return $robots;
         }
    	return $robots;
    });

    Is the above code correct if I want to target multiple categories?

    Alberto
    Rank Math business

    Hello,

    It is almost fine, but you need to divide the condition. I have modified the code to match what you want:

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $post;
         // filter for only a specific post type
         switch(get_category()){
            case "ean":
            case "model":
            case "eanlist":
            case "upc":
            case "partnumber":
            case "upclist":
            case "studio":
            case "manufacturer":
            case "mpn":
            case "label":
            case "home-base":
            case "producttypename":
            case "size":
            case "productgroup":
            case "warranty":
            case "packagequantity":
            case "item-model-number":
            case "catalognumberlist":
            case "publisher":
            case "product partnumber":
            case "size array/list":
              $robots['index'] = "noindex";
              break;
            default:
              break;
         }
         return $robots;
    });

    Looking forward to help you.

    What happens if I already no index a couple of these through rank math plugin? Would an error be likely to occur or it be ignored?

    Thank you again guys, after I implement this, how long does it take for google to see this? Is there any additional action on my part that’s needed or can be done to move this process along faster?

    Hello,

    It is unlikely it causes an error, but in case there is an issue you can always get in touch with us so we can assist.

    You can choose to ask Google to re-index your site or you can wait until google crawls and indexes your site again.

    Hope that helps you. Thank you.

    ​​​​​​

    Do i have to delete my already submitted site map made wit rank math and resubmit it? I have over 900 links on my site and wondering what’s the best and fastest way to do this? How will google see the applied code changes above that was added to my function.php child theme.

    Alberto
    Rank Math business

    Hello,

    No, you don’t need to delete it. It will be updated automatically, also when Google crawls those links, it will detect it is as “no-index”.

    So right now you don’t have to worry about it, everything should be fine, and as my colleague said, if you have issues, we will be here to help you.

    Looking forward to help you.

    Thank you so much guys! I’ll keep this open and report about in about a week for google to do it’s thing. Will it still show up in cached search results in google? Either way, I’ll let you guys know what happens. Thanks again!

    I get an error when I added this to my child theme function.php, is the syntax right?

    I get the following:
    There has been a critical error on your website.

    Learn more about debugging in WordPress.

    Stone
    Rank Math free

    It can be easily done manually. You will see an option for the same in the left side panel

    Can you explain this a bit more in-depth please?

    Alberto
    Rank Math business

    Hello,

    I think stone is suggesting you to do it by setting each category manually but as you said, you have 900+ links so it would be a really hard work.

    If you want, we could take a closer look at the code on your site and try to fix it for you. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping 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 15 replies - 1 through 15 (of 18 total)

The ticket ‘how to remove all unwanted categories in woocommerce archive pages.’ is closed to new replies.