# Forgotten Drafts Widget

> Adds a dashboard widget listing drafts nobody has touched for over 30 days, oldest first, with their author, so half-finished ideas get finished or cleaned up.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard-widget, drafts, editorial
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dash-forgotten-drafts-widget/

## Code

```php
// Days without changes before a draft counts as forgotten.
$wpide_forgotten_days = 30;

add_action( 'wp_dashboard_setup', function () use ( $wpide_forgotten_days ) {
    wp_add_dashboard_widget( 'wpide_forgotten_drafts', 'Forgotten drafts', function () use ( $wpide_forgotten_days ) {
        $args = array(
            'post_type'      => array( 'post', 'page' ),
            'post_status'    => 'draft',
            'posts_per_page' => 10,
            'orderby'        => 'modified',
            'order'          => 'ASC',
            'no_found_rows'  => true,
            'date_query'     => array( array( 'column' => 'post_modified_gmt', 'before' => $wpide_forgotten_days . ' days ago' ) ),
        );
        if ( ! current_user_can( 'edit_others_posts' ) ) {
            $args['author'] = get_current_user_id();
        }
        $drafts = get_posts( $args );

        if ( ! $drafts ) {
            echo '<p>No forgotten drafts.</p>';
            return;
        }

        echo '<ul>';
        foreach ( $drafts as $draft ) {
            printf(
                '<li><a href="%s">%s</a><br><small>%s &middot; last edited %s ago</small></li>',
                esc_url( get_edit_post_link( $draft ) ),
                esc_html( get_the_title( $draft ) ? get_the_title( $draft ) : '(no title)' ),
                esc_html( get_the_author_meta( 'display_name', $draft->post_author ) ),
                esc_html( human_time_diff( get_post_modified_time( 'U', true, $draft ) ) )
            );
        }
        echo '</ul>';
    } );
} );
```

## Notes

Editors see everyone's drafts; authors only see their own.

## How to use it

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