# Exclude Specific Posts From the All in One SEO Sitemap

> Keeps the posts and pages you list out of All in One SEO's XML sitemap.

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

## Code

```php
// IDs to leave out.
$wpide_aioseo_sitemap_exclude = array( 12, 34 );

add_filter( 'aioseo_sitemap_exclude_posts', function ( $ids, $type ) use ( $wpide_aioseo_sitemap_exclude ) {
    return array_unique( array_merge( (array) $ids, array_map( 'intval', $wpide_aioseo_sitemap_exclude ) ) );
}, 10, 2 );
```

## Notes

The posts stay indexable; only the sitemap entry is removed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Exclude Specific Posts From the All in One SEO 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/
