# Hide Items in a Term From a Post Type Archive

> Keeps items filed under certain terms (such as "Archived" or "Internal") off a post type's main archive, while their own term archive still lists them.

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

## Code

```php
// Post type archive, taxonomy and term slugs to hide.
$wpide_hide_terms = array(
    'post_type' => 'job',
    'taxonomy'  => 'job_type',
    'terms'     => array( 'internal' ),
);

add_action( 'pre_get_posts', function ( $query ) use ( $wpide_hide_terms ) {
    if ( is_admin() || ! $query->is_main_query() || ! $query->is_post_type_archive( $wpide_hide_terms['post_type'] ) || ! taxonomy_exists( $wpide_hide_terms['taxonomy'] ) ) {
        return;
    }

    $tax_query   = (array) $query->get( 'tax_query' );
    $tax_query[] = array(
        'taxonomy' => $wpide_hide_terms['taxonomy'],
        'field'    => 'slug',
        'terms'    => $wpide_hide_terms['terms'],
        'operator' => 'NOT IN',
    );

    $query->set( 'tax_query', $tax_query );
} );
```

## Notes

Set the post type, taxonomy and term slugs.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Items in a Term From a Post Type Archive" 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/
