# Noindex an Entire Post Type

> Keeps every entry and the archive of chosen post types out of search results and removes them from the built-in XML sitemap, while visitors can still open them.

- Type: PHP
- Runs: Run everywhere
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: noindex, custom-post-types, sitemap
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/seo-noindex-post-type/

## Code

```php
// Post types to keep out of search engines.
$wpide_noindex_types = array( 'testimonial', 'partner' );

add_filter( 'wp_robots', function ( $robots ) use ( $wpide_noindex_types ) {
    if ( is_singular( $wpide_noindex_types ) || is_post_type_archive( $wpide_noindex_types ) ) {
        $robots['noindex'] = true;
        $robots['follow']  = true;
    }

    return $robots;
} );

add_filter( 'wp_sitemaps_post_types', function ( $post_types ) use ( $wpide_noindex_types ) {
    return array_diff_key( $post_types, array_flip( $wpide_noindex_types ) );
} );
```

## Notes

Useful for thank-you pages, internal resources or thin listings. SEO plugins have their own per-type setting.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Noindex an Entire Post Type" 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/
