# "Recently Edited" Menu in the Admin Bar

> Adds a menu to the admin bar listing the last eight posts and pages you edited, with their status, so you can jump back into your work from anywhere on the site.

- Type: PHP
- Runs: Run everywhere
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin-bar, navigation, productivity
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-bar-recently-edited/

## Code

```php
// Number of items to list.
$wpide_recent_count = 8;

add_action( 'admin_bar_menu', function ( $admin_bar ) use ( $wpide_recent_count ) {
    if ( ! current_user_can( 'edit_posts' ) ) {
        return;
    }

    $posts = get_posts( array(
        'post_type'      => 'any',
        'post_status'    => array( 'publish', 'draft', 'pending', 'future', 'private' ),
        'posts_per_page' => $wpide_recent_count,
        'orderby'        => 'modified',
        'meta_key'       => '_edit_last',
        'meta_value'     => get_current_user_id(),
        'no_found_rows'  => true,
    ) );

    if ( ! $posts ) {
        return;
    }

    $admin_bar->add_node( array(
        'id'    => 'wpide-recent-edits',
        'title' => '<span class="ab-icon dashicons dashicons-backup" style="margin-top:2px" aria-hidden="true"></span><span class="ab-label">Recent</span>',
    ) );

    foreach ( $posts as $post ) {
        $admin_bar->add_node( array(
            'id'     => 'wpide-recent-' . $post->ID,
            'parent' => 'wpide-recent-edits',
            'title'  => esc_html( wp_trim_words( get_the_title( $post ) ? get_the_title( $post ) : '(no title)', 8 ) . ( 'publish' !== $post->post_status ? ' - ' . $post->post_status : '' ) ),
            'href'   => get_edit_post_link( $post->ID, 'url' ),
        ) );
    }
}, 80 );
```

## Notes

Based on WordPress's own "last edited by" record; change $wpide_recent_count for a longer list.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Recently Edited" Menu in the Admin Bar" 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/
