admin管理员组

文章数量:1431769

I want to modify the pages search in the 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 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 clarify that the post_type is page, but I don't know how and where.

本文标签: filtersAdmin BackendSearch Pages only by title