Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#17230 closed enhancement (wontfix)

Make the search widget better.

Reported by: JonezJeA Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Widgets Keywords:
Focuses: Cc:


If a user knows the stuff he is looking for is in a post why does the search bar needs to look for pages or plug ins also? It is a waste of time!
At many sites you can choose to search in the posts or in the pages only and I think it would be a handy feature in WordPress too!

Change History (3)

#1 @JonezJeA
5 years ago

  • Type changed from defect (bug) to enhancement

#2 @nacin
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This can be done in a plugin. Our current widget is as simple as possible and there's no need to add existing UI elements.

You can pass a post_type field via your own search widget and WP_Query will handle that.

#3 @ocean90
5 years ago

Example code:

function my_exclude_pages_from_search( $query ) {
	if ( $query->is_search )
		$query->set(  'post_type', 'post' );

	return $query;

add_filter( 'pre_get_posts', 'my_exclude_pages_from_search' );
Note: See TracTickets for help on using tickets.