# Rank Math Sitemap: Leave Out Whole Post Types

> Removes entire post types from the Rank Math sitemap index regardless of the sitemap settings screen.

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

## Code

```php
// Post types to leave out.
$wpide_rm_skip_types = array( 'landing', 'attachment' );

add_filter( 'rank_math/sitemap/exclude_post_type', function ( $exclude, $type ) use ( $wpide_rm_skip_types ) {
    return in_array( $type, $wpide_rm_skip_types, true ) ? true : $exclude;
}, 10, 2 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Rank Math Sitemap: Leave Out Whole Post Types" 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/
