Exclude posts or taxonomies from sitemap (slimseo)

If you are using SlimSeo plugin it automatically add all posts and taxonomies into sitemap.xml file. This snippet allows you to exclude some post types and taxonomies from sitemap file.

add_filter( 'slim_seo_sitemap_post_types', function( $post_types ) {
    $post_types = array_diff( $post_types, ['help','slider']  );
    return $post_types;
} );

add_filter( 'slim_seo_sitemap_taxonomies', function( $taxonomies ) {
    $taxonomies = array_diff( $taxonomies, ['category'] );
    return $taxonomies;
} );

In this snippet above from sitemaps file will exclude ‘help’ and ‘slider’ post type, and ‘category’ taxonomy.

Click to Copy