Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

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

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

Avatar of Robert Granlund
Robert Granlund
Flag of United States of America image

ASKER

I found my answer in a forum
ASKER CERTIFIED SOLUTION
Avatar of Robert Granlund
Robert Granlund
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial