filters - Admin Backend - Search Pages only by title

I want to modify the pages search in the Admin Backend, so that the search only factor the title of the pages and not th

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745588105a4634667.html

相关推荐

  • filters - Admin Backend - Search Pages only by title

    I want to modify the pages search in the Admin Backend, so that the search only factor the title of the pages and not th

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信