Admin Backend – Search Pages only by title

I want to modify the pages search in den Admin Backend, so that the search only factor the title of the pages and not the whole text/article. I already found a code for the functions.php that works perfectly for posts but not for pages.

Here is the code for posts:

add_filter( ‘posts_search’, ‘admin_search_shops’, null, 2 );
function admin_search_shops( $search, $a_wp_query ) {

if ( !is_admin() ) return $search;

$search = preg_replace( “# OR (.*posts.post_content LIKE ‘%.*%’)#”, “”, $search );

return $search;

I`m quite a noob in php, so I only know that I probably have to add some code to clearify that the ‘post_type’ is ‘page’, but I don’t know how and where?

Read more here:: Admin Backend – Search Pages only by title

Leave a Reply

Your email address will not be published. Required fields are marked *