How do I exclude a category from the XML sitemap in Wordpress

Robert Granlund
Robert Granlund used Ask the Experts™
on
Wordpress / Yoast.  i have a lot of Draft Pages in my wordpress CMS.  Yoast will not put them in the sitemap if I mark them to be excluded, but there are too many to go through.  They are all in one category.  I want Yoast to not place a specific category (or taxonomy, which ever is easier) in my XML sitemap.  The reason is, Google will index Draft and private pages and I don't want that because they will come up 404.

How do I exclude a category from the XML sitemap in Wordpress

I found this but I dont think it is what I want

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

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I found my answer in a forum
I found my soultio in a forum

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial