Exclude categories | WordPress.org

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?

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.

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) …

// 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.

Thank you! It worked!

I just had to add a ) at the end of the condition.


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer