Title: Exclude posts with tag
Last modified: August 14, 2025

---

# Exclude posts with tag

 *  Resolved [nitrospectide](https://wordpress.org/support/users/nitrospectide/)
 * (@nitrospectide)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/)
 * Is there a way to make the sitemap not include posts that have a particular taxonomy
   term applied to them?

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

 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * (@rankmathsupport)
 * [8 months ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18606527)
 * Hello [@nitrospectide](https://wordpress.org/support/users/nitrospectide/),
   Thank
   you for contacting Rank Math support.You can modify and use the following filter
   to exclude the posts with a specific term from the sitemap:
 *     ```wp-block-code
       add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){ return $url;}, 10, 3 );
       ```
   
 * If you want us to modify it, please share the taxonomy and term name.
   Looking
   forward to helping you.
 *  Thread Starter [nitrospectide](https://wordpress.org/support/users/nitrospectide/)
 * (@nitrospectide)
 * [8 months ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18607035)
 * taxonomy: success_types
 * term: testimonials
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * (@rankmathsupport)
 * [8 months ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18609777)
 * Hello [@nitrospectide](https://wordpress.org/support/users/nitrospectide/),
   Please
   use the following filter to exclude the posts that have the “testimonial” term
   from the sitemap:
 *     ```wp-block-code
       add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {    // Only run for posts    if ( 'post' === $type && $object instanceof WP_Post ) {        // Check if post has the term "testimonials" in taxonomy "success_types"        if ( has_term( 'testimonials', 'success_types', $object->ID ) ) {            return false; // Exclude from sitemap        }    }    return $url; // Keep others}, 10, 3 );
       ```
   
 * Hope that helps and please do not hesitate to let us know if you need our assistance
   with anything else.
 *  Thread Starter [nitrospectide](https://wordpress.org/support/users/nitrospectide/)
 * (@nitrospectide)
 * [7 months, 3 weeks ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18616042)
 * Thank you. I used your code with one minor tweak to reference the post type key,
   instead of just ‘post’
 *     ```wp-block-code
       add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {    // Only run for posts    if ( 'success_stories' === $type && $object instanceof WP_Post ) {        // Check if post has the term "testimonials" in taxonomy "success_types"        if ( has_term( 'testimonials', 'success_types', $object->ID ) ) {            return false; // Exclude from sitemap        }    }    return $url; // Keep others}, 10, 3 );
       ```
   
 * Then to regenerate the sitemap, it’s my understanding that I need to change the
   Links Per Sitemap setting and save it. But the posts I was trying to remove from
   my sitemap are still there.
 *  Plugin Support [Jaideep Asrani](https://wordpress.org/support/users/jaideeprm/)
 * (@jaideeprm)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18625755)
 * Hello [@nitrospectide](https://wordpress.org/support/users/nitrospectide/),
 * Please share the sitemap URL so we can check and assist you further.
   Looking 
   forward to helping you.
 *  Thread Starter [nitrospectide](https://wordpress.org/support/users/nitrospectide/)
 * (@nitrospectide)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18626369)
 * eos-gnss.com/success_stories-sitemap.xml
 * All success stories with ‘testimonials’ in the URL should be hidden, since they
   have the testimonials taxonomy term applied to them. Example:
 * /successses/testimonials/tommy-shifflett
    -  This reply was modified 7 months, 2 weeks ago by [nitrospectide](https://wordpress.org/support/users/nitrospectide/).
 *  Thread Starter [nitrospectide](https://wordpress.org/support/users/nitrospectide/)
 * (@nitrospectide)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18626384)
 * Also: I just noticed that there are 79 posts with this term applied, and it’s
   only 2 that are showing in the sitemap. The 2 have ‘Index’ checked in the Rank
   Math section of the post edit screen, while the others all appear to have ‘No
   Index’ checked.
 * My goal with this code is to override the Index/No Index setting so that admins
   could not let these slip through to the sitemap by forgetting to check ‘No Index.’
 *  Plugin Support [Jaideep Asrani](https://wordpress.org/support/users/jaideeprm/)
 * (@jaideeprm)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18631759)
 * Hello [@nitrospectide](https://wordpress.org/support/users/nitrospectide/),
 * The code should work fine if the taxonomy and post type slug are correct. Please
   follow this screencast to clear the sitemap cache: [https://i.rankmath.com/pipRDp](https://i.rankmath.com/pipRDp)
   
   If the issue persists, please get in touch with our development team at [support@rankmath.com](https://wordpress.org/support/topic/exclude-posts-with-tag-2/support@rankmath.com?output_format=md)
   so they can check this further.Looking forward to helping you.

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

The topic ‘Exclude posts with tag’ is closed to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [Jaideep Asrani](https://wordpress.org/support/users/jaideeprm/)
 * Last activity: [7 months, 1 week ago](https://wordpress.org/support/topic/exclude-posts-with-tag-2/#post-18631759)
 * Status: resolved