# Register an "Archived" Post Status

> Adds an "Archived" status for posts that should leave the site without being deleted, with its own filter link in the Posts list and a status choice in the editor.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: post-status, workflow, content, admin
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-register-post-status/

## Code

```php
add_action( 'init', function () {
    register_post_status( 'wpide_archived', array(
        'label'                     => 'Archived',
        'public'                    => false,
        'protected'                 => true,
        'exclude_from_search'       => true,
        'show_in_admin_all_list'    => false,
        'show_in_admin_status_list' => true,
        /* translators: %s: number of posts */
        'label_count'               => _n_noop( 'Archived <span class="count">(%s)</span>', 'Archived <span class="count">(%s)</span>' ),
    ) );
} );

add_action( 'admin_footer-edit.php', function () {
    global $post_type;

    if ( 'post' !== $post_type ) {
        return;
    }
    ?>
<script>
jQuery(function ($) {
    $('select[name="_status"]').append('<option value="wpide_archived">Archived</option>');
});
</script>
    <?php
} );

add_filter( 'display_post_states', function ( $states, $post ) {
    if ( 'wpide_archived' === $post->post_status && ( ! isset( $_GET['post_status'] ) || 'wpide_archived' !== $_GET['post_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        $states['wpide_archived'] = 'Archived';
    }

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

## Notes

Archived posts are not public. Set them via Quick Edit or the status dropdown in the block editor's summary panel.

## How to use it

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