• Resolved mukesh jatt

    (@starsb0641)


    hello i used below code to noindex all posts in a 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;
    });

    but these posts are in yoast sitemap. any code to exclude noindex urls from sitemap ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • By default, any posts that you’d set to No from the Yoast SEO meta box advanced option → show this post on search results will be automatically excluded from the sitemap generated by Yoast SEO. You can find more information about this here.

    Thread Starter mukesh jatt

    (@starsb0641)

    but i can’t do it manually one by one
    if there is a way to exclude specific category’s post that would be nice.

    Plugin Support Maybellyne

    (@maybellyne)

    Hello,

    You can noindex a specific category by following these steps:

    • Go to Posts → Categories.
    • Click ‘Edit’ on the specific category
    • Scroll down to the Yoast meta box and expand the “Advanced” tab
    • Choose ‘No’ for the option to ‘Allow search engines to show this Category in search results?’
    • That should add “noindex” tag to all the posts included in this category.

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

    @starsb0641 You can find PHP snippet on github – https://github.com/Yoast/wordpress-seo/issues/387

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

The topic ‘How to exclude noindex posts from sitemap’ is closed to new replies.