WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 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:

Description

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)

comment:1 @JonezJeA4 years ago

  • Type changed from defect (bug) to enhancement

comment:2 @nacin4 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.

comment:3 @ocean904 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.