WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9230 closed enhancement (duplicate)

Option to search for posts, pages or both

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

Description

Hi.

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';

else

$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.
Thanks!

Change History (6)

comment:1 ryan5 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.

comment:2 jidm5 years ago

Yes, that would be great!

comment:3 FFEMTcJ5 years ago

  • Milestone changed from 2.7.2 to Future Release

comment:4 FFEMTcJ5 years ago

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

comment:5 jidm5 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.

Thanks!

comment:6 Denis-de-Bernardy5 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.