Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9230 closed enhancement (duplicate)

Option to search for posts, pages or both

Reported by: jidm's profile jidm Owned by:
Milestone: Priority: low
Severity: minor Version:
Component: General Keywords: search options pages posts needs-patch
Focuses: Cc:



I seriously believe that there should be an option to choose between search on 'any' or 'post'. This could be set from the admin panel.

In some projects i don't need/want to searh on pages, so i have to manually change 'any' for 'post' on wp-includes/query.php:

if ( !isset($qpost_type?) ) {

if ( $this->is_search )

$qpost_type? = 'any';


$qpost_type? = 'post';

I think this can't be hard to implement (an option in the backend, a row in wp_options [maybe wp_blogs in case of wpmu] and a modification on the code above to ask for that option).

Please consider implementing this.

Change History (6)

#1 @ryan
14 years ago

We can add a filter so plugins and themes can change this. I don't think we need an option in the UI.

#2 @jidm
14 years ago

Yes, that would be great!

14 years ago

  • Milestone changed from 2.7.2 to Future Release

14 years ago

  • Priority changed from normal to low
  • Severity changed from normal to minor

#5 @jidm
14 years ago

  • Cc jidm added

I tried to make it work by using the following hack before the have_posts call:

<?php $wp_query->set('post_type', 'post'); ?>

But nothing happened. Please consider having a look on it, as it doesn't seem to be hard work, and is a plus feature for a minority of users.


#6 @Denis-de-Bernardy
14 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

see #9785

Note: See TracTickets for help on using tickets.