最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - Admin Backend - Search Pages only by title

programmeradmin8浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论