# "Needs Review" View for Outdated Posts

> Adds a "Needs review" link above the Posts list that shows published posts not updated for a year or more, so editors can keep old content accurate.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: content-audit, admin-lists, editorial
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-needs-review-view/

## Code

```php
// Posts not modified for this many months need a review.
$wpide_review_months = 12;

add_filter( 'views_edit-post', function ( $views ) use ( $wpide_review_months ) {
    $count = get_transient( 'wpide_needs_review_count' );
    if ( false === $count ) {
        $query = new WP_Query( array(
            'post_type'      => 'post',
            'post_status'    => 'publish',
            'posts_per_page' => 1,
            'fields'         => 'ids',
            'date_query'     => array( array( 'column' => 'post_modified_gmt', 'before' => $wpide_review_months . ' months ago' ) ),
        ) );
        $count = (int) $query->found_posts;
        set_transient( 'wpide_needs_review_count', $count, HOUR_IN_SECONDS );
    }

    $current = ! empty( $_GET['wpide_review'] );
    $views['wpide_review'] = sprintf(
        '<a href="%s"%s>Needs review <span class="count">(%d)</span></a>',
        esc_url( admin_url( 'edit.php?post_status=publish&wpide_review=1&orderby=modified&order=asc' ) ),
        $current ? ' class="current" aria-current="page"' : '',
        (int) $count
    );
    return $views;
} );

add_action( 'pre_get_posts', function ( $query ) use ( $wpide_review_months ) {
    if ( ! is_admin() || ! $query->is_main_query() || empty( $_GET['wpide_review'] ) ) {
        return;
    }
    $query->set( 'date_query', array( array( 'column' => 'post_modified_gmt', 'before' => $wpide_review_months . ' months ago' ) ) );
} );
```

## Notes

Change $wpide_review_months; the count in the link is cached for an hour.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Needs Review" View for Outdated Posts" 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/
