# Show Authors Only Their Own Posts in Admin Lists

> Users who cannot edit other people's posts, like authors and contributors, see only their own items in the admin lists.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin, authors, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/authors-see-only-own-posts/

## Code

```php
add_action( 'pre_get_posts', function ( $query ) {
    global $pagenow;

    if ( ! is_admin() || ! $query->is_main_query() || 'edit.php' !== $pagenow ) {
        return;
    }

    $post_type = $query->get( 'post_type' ) ? $query->get( 'post_type' ) : 'post';
    $object    = get_post_type_object( is_array( $post_type ) ? reset( $post_type ) : $post_type );

    if ( $object && ! current_user_can( $object->cap->edit_others_posts ) ) {
        $query->set( 'author', get_current_user_id() );
    }
} );
```

## Notes

The counts above the list (All, Published) still include other people's posts.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Authors Only Their Own Posts in Admin Lists" 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/
