# Exclude Post Types From the Yoast Sitemap

> Removes whole post types, such as landing pages or a plugin's internal post type, from the Yoast SEO sitemap index.

- Type: PHP
- Runs: Frontend only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: yoast, sitemap, custom-post-types
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/yoast-sitemap-exclude-post-types/

## Code

```php
// Post type names to leave out of the sitemap.
$wpide_sitemap_skip_types = array( 'landing', 'attachment' );

add_filter( 'wpseo_sitemap_exclude_post_type', function ( $excluded, $post_type ) use ( $wpide_sitemap_skip_types ) {
    return in_array( $post_type, $wpide_sitemap_skip_types, true ) ? true : $excluded;
}, 10, 2 );
```

## Notes

To also hide them from search, set them to noindex in Yoast's Content types settings.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Exclude Post Types From the Yoast Sitemap" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
