Title: Exclude custom posts from sitemap programmatically
Last modified: August 31, 2016

---

# Exclude custom posts from sitemap programmatically

 *  Resolved [jsnd](https://wordpress.org/support/users/jsnd/)
 * (@jsnd)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/exclude-custom-posts-from-sitemap-programmatically/)
 * Hello,
 * I have a custom post type which has a field “has_detail_page”, which can be set
   while editing a post of this type.
 * Now I would like to exclude posts which do not have a detail page, exclude from
   WordPress.
 * Of course I could add those posts manually to “Posts to exclude” field in sitemap
   configuration. But this is not very comfortable.
 * Is there a filter before the post is outputted to the sitemap?
    Or, if it does
   not work with a filter, do I have the possibility to fill “Posts to exclude” 
   programmatically?
 * Thank you!
 * [https://wordpress.org/plugins/wordpress-seo/](https://wordpress.org/plugins/wordpress-seo/)

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

 *  Thread Starter [jsnd](https://wordpress.org/support/users/jsnd/)
 * (@jsnd)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/exclude-custom-posts-from-sitemap-programmatically/#post-7441655)
 * Does nobody have an idea? That can`t be impossible?
 * I just need a filter to exclude specific posts from the sitemap automatically…
 *  [Josh Feck](https://wordpress.org/support/users/builtbynorthby/)
 * (@builtbynorthby)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/exclude-custom-posts-from-sitemap-programmatically/#post-8610865)
 * You can use the `wpseo_sitemap_entry` filter hook.
 * [https://github.com/Yoast/wordpress-seo/blob/trunk/inc/sitemaps/class-post-type-sitemap-provider.php#L253](https://github.com/Yoast/wordpress-seo/blob/trunk/inc/sitemaps/class-post-type-sitemap-provider.php#L253)

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

The topic ‘Exclude custom posts from sitemap programmatically’ is closed to new 
replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [sitemap](https://wordpress.org/support/topic-tag/sitemap/)
 * [Yoast](https://wordpress.org/support/topic-tag/yoast/)

 * 2 replies
 * 2 participants
 * Last reply from: [Josh Feck](https://wordpress.org/support/users/builtbynorthby/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/exclude-custom-posts-from-sitemap-programmatically/#post-8610865)
 * Status: resolved