# Turn Off the Archive Page of a Post Type

> Removes the automatic archive page of a post type, for example when you build the listing yourself on a regular page with the same URL.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: archives, custom-post-types, permalinks
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-post-type-archive/

## Code

```php
// Post types without an archive page.
$wpide_no_archive_types = array( 'portfolio' );

add_filter( 'register_post_type_args', function ( $args, $post_type ) use ( $wpide_no_archive_types ) {
    if ( in_array( $post_type, $wpide_no_archive_types, true ) ) {
        $args['has_archive'] = false;
    }

    return $args;
}, 10, 2 );
```

## Notes

Visit Settings > Permalinks once afterwards so a page with that slug can take over the URL.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Turn Off the Archive Page of a 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/
