WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone have any suggestions on how to limit the search in the WP admin area to just post titles? It's very frustrating to want to pull up a specific page, and get hundreds of results that have that word in the post content.

share|improve this question

This is possible by altering the search query via the posts_search hook.


A default search query will look like this:

..AND (((wp_posts.post_title LIKE \'%search terms%\') OR (wp_posts.post_content LIKE \'%search terms%\')))

We need to remove the post content search, a regular expression should be enough.

add_filter( 'posts_search', 'wpse_45153_filter_search', null, 2 );
function wpse_45153_filter_search( $search, $a_wp_query ) {
    if ( !is_admin() ) return $search; // work only in the dashboard

    $search = preg_replace( "# OR \(.*posts\.post_content LIKE \\'%.*%\\'\)#", "", $search );

    return $search;

Note that the regular expression has not been thoroughly tested and may have edge cases when other plugins or themes alter hook into here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.