# Disable Date Archives

> Makes yearly, monthly and daily archive pages return a 404, which avoids thin duplicate pages on most sites.

- Type: PHP
- Runs: Run everywhere
- Category: [Archives](https://wpide.com/library/category/archive/)
- Tags: archive, date, seo
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-date-archives/

## Code

```php
add_action( 'template_redirect', function () {
    global $wp_query;

    if ( is_date() ) {
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();
    }
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable Date Archives" 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/
