• Resolved Theo

    (@dubeux)


    Hi,
    I’ve read this question, which led me to this request at github, which makes me believe you’ve done it, but I couldn’t understand: is there a way to exclude one specific category posts from the sitemap? I mean, is it doable for a non-coder?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    You can exclude a certain taxonomy by setting it to noindex using the Yoast SEO plugin.

    Thread Starter Theo

    (@dubeux)

    Thanks for the reply, but I can’t find a way to do what I want in Yoast. I can exclude a category, which means, afaik, its initial page, and I can exclude categories, broadly. What I want is to exclude a certain category posts – only its posts. Is it possible? Or do I need to exclude each post separately?

    MariusG

    (@marius_codeinwp)

    Hi @dubeux,

    Thank you for getting back to us with details.

    Unfortunately, it is not currently possible to noindex all posts in a given category using Yoast SEO’s features/dashboard.

    If you are comfortable with adding PHP snippets to your theme, you can use the following one to noindex all posts in a specific category:

    /* Noindex all posts in a category */
    add_filter("wpseo_robots", function($robots) {
      if (is_single() && in_category(array(100))) {
        return "noindex,follow";
      }
      return $robots;
    });

    Replace 100 with the actual ID of your category.

    Thread Starter Theo

    (@dubeux)

    Hey @marius_codeinwp, thank you very much for the code. It works perfectly, but unfortunately the posts are still showing up on the sitemap (despite having the noindex tag).
    It’s a bit weird, seems to be related to another plugin – Events manager. I’ll ask for them, thank you for your support.

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    This is to be expected as the filter wpseo_robots was designed it like this way. Please, refer to our this issue report to learn more about why it was designed in such way and how can you remove items from sitemap.

    Thread Starter Theo

    (@dubeux)

    Sorry to bother with something related to basic php syntax, but I’m not being able to add the wpseo_exclude_from_sitemap_by_post_ids filter to the snippet provided. May I ask you to guide me on that?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to exclude one specific category’ is closed to new replies.