Title: Exclude categories
Last modified: September 16, 2023

---

# Exclude categories

 *  Resolved [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/exclude-categories-48/)
 * Hello. Is it possible to exclude categories from the normal sitemap?
 * Thanks.

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

 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17055948)
 * Hi, do you wish to exclude certain category archive pages from the categories
   sitemap or exclude all posts that belong to a certain category from the posts
   sitemap?
 *  Thread Starter [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17056064)
 * Hi. I need to exclude all posts (1417 posts) that belong to certain category 
   from posts sitemap.
   I didn’t think about the category archive pages, but it would
   be great if I also could exclude it from the categories sitemap.I mean, I wish
   to exclude from my sitemap.xml everything about certain category.
 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17056100)
 * Hi, this is not possible with the free version but is planned for the upcoming
   Pro version.
 * However, you could use the below code snippet to achieve at least the Posts exclusion
   part. The code snippets can be added either to your custom/child theme’s functions.
   php or using a “Code Snippets” plugin (there are several plugins available on
   wp.org) …
 *     ```wp-block-code
       // Exclude posts that belong to category by ID.
       function my_custom_exclusion( $exclude, $post_id ) {
           // Change this to match your category ID number.
           $cat_id = 123;
   
           if ( in_array( $cat_id, (array) wp_get_post_categories( $post_id ) ) {
               return true;
           }
   
           // Return original status.
           return $exclude;
       }
       add_filter( 'xmlsf_excluded', 'my_custom_exclusion', 10, 2 );
       ```
   
 * Excluding a particular taxonomy term is not possible yet. Your only option is
   to disable the complete Category taxonomy or all taxonomy sitemaps.
 *  Thread Starter [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17056437)
 * Thank you! It worked!
 * I just had to add a ) at the end of the condition.
 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17057726)
 * My apologies for the missing ), I must admit I did not verify my sloppy code…
   Good to hear you fixed it 🙂

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

The topic ‘Exclude categories’ is closed to new replies.

 * ![](https://ps.w.org/xml-sitemap-feed/assets/icon-128x128.png?rev=1112143)
 * [XML Sitemap & Google News](https://wordpress.org/plugins/xml-sitemap-feed/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/xml-sitemap-feed/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/xml-sitemap-feed/)
 * [Active Topics](https://wordpress.org/support/plugin/xml-sitemap-feed/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/xml-sitemap-feed/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/xml-sitemap-feed/reviews/)

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)

 * 5 replies
 * 2 participants
 * Last reply from: [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/exclude-categories-48/#post-17057726)
 * Status: resolved