• Resolved Jonas

    (@gnuworld)


    Hi

    On our site we have all WooC. products set to not be shown in search results.

    We have however used hooks to get Yoast SEO to make exceptions to that rule based on which product categories products are in. I.e. for products in certain categories we are setting index, follow meta directives.

    This works fine.

    What we are struggling to do however is to now also get those same products into the sitemap. Our dev does not seem to find a possible way of doing this with the existing hooks.

    Is there any way to get Yoast to include products that live in particular products categories into the XML sitemap?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello Jonas,

    Thanks for reaching out.

    To be sure I understand you correctly, you will like to show some product categories in the product sitemap though you have set all WooCommerce products not to be shown in search results. Is this correct?

    I believe the set-up should be the other way round. You should set products to show in search results. This automatically creates a product sitemap. Then, you can set specific categories not to be indexed. These won’t be shown in the sitemap. But setting all products not to be shown will mean no sitemap to start with.

    Thread Starter Jonas

    (@gnuworld)

    Hi @maybellyne

    OK, I have set all products to be shown in search results in the settings.

    And our hooks set the correct meta robots directives at the product level. I can see on the front-end that we have set the robots for some products to ‘index’ and ‘noindex’ for others.

    But the sitemap now still contains all of the products which have “noindex” meta robots directives. I cleared all caches and deactivated and reactivated the sitemap functionality in Yoast and the problem remains.

    Our developer also tried using your wpseo_exclude_from_sitemap_by_post_ids hook but says that he can’t get that hook to work at all. I’ve seen several reports by other people online that they could not get that hook to work either.

    You can see our code here: https://collabedit.com/9b7sj (enter any name)

    Is there something that we are missing?

    • This reply was modified 3 years, 4 months ago by Jonas.
    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    As much as we hate to say it, your question goes beyond the technical expertise of me and my colleagues on the Yoast support team. This means we can’t give you a solid answer to your question.

    But we don’t want to leave you empty-handed either, that’s why we’ve created our developer portal at developer.yoast.com. This has proven to be useful to many developers in the past and hopefully will serve you well too.

    That said, we used to have an issue report about this on GitHub that you could find here https://github.com/Yoast/wordpress-seo/issues/9422. We recommend you please check the relevant issue to see if there’s anything you’re missing. You could even communicate directly to our development through the relevant issue as well.

    Sorry, we can’t be of more help here.

    Sa?a

    (@stodorovic)

    @gnuworld You can find more details (and PHP snippets) – https://github.com/Yoast/wordpress-seo/issues/387, but you need to modify these examples.
    The easiest way is the filter wpseo_exclude_from_sitemap_by_post_ids which will exclude everything except products from particular product category. It should work. I never saw issues related to this filter.

    Thread Starter Jonas

    (@gnuworld)

    Thank you all. Our dev managed to get this working, so am marking this as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add URLs from product category into sitemap’ is closed to new replies.