Find Posts by ID in the Admin Search
Type #123 or id:123 in the posts or pages search box to jump straight to the item with that ID.
Opens WPIDE on
Code
add_action( 'pre_get_posts', function ( $query ) {
global $pagenow;
if ( ! is_admin() || ! $query->is_main_query() || 'edit.php' !== $pagenow ) {
return;
}
$search = trim( (string) $query->get( 's' ) );
if ( preg_match( '/^(?:#|id:\s*)(\d+)$/i', $search, $match ) ) {
$query->set( 's', '' );
$query->set( 'p', (int) $match[1] );
}
} );
Notes
Plain numbers are still searched as text, so titles like "2025" keep working.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.