Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Improve WordPress Search WordPress


Hi, I am trying to improve the WordPress search to allow for a search of the custom post types. There is a custom post type called "members" that is not being searched by the current search function.

Users should be able to search the members directory by company titles or terms. Currently nothing is being pulled.

I have tried using [[LINK href=""]]Relevannsi[[/LINK]] and [[LINK href=""]]Search Everything[[/LINK]], but neither have worked.

Here is the search I am trying to improve:

Any suggestions would be appreciated. Thanks!

Answers (3)


Pippin Williamson answers:

The first thing you can do is include the Members post type in the search query. It's excluded by default. To enable it, put this in your functions.php:

function add_members_to_search( $query ) {
if ( $query->is_search ) {
'post_type', array( 'post', 'page', 'members' ));
return $query;
add_filter( 'the_search_query', 'customSearch' );


Julio Potier answers:


Check the codex :
and focus on "exclude_from_search"

Check your "register_post_type" in your plugin or functions.php (from theme)

See you


Ivaylo Draganov answers:


Try this code:

function include_custom_posts_in_search( $query ) {

if ( is_search() ) {
$query->set( 'post_type', array ( 'post', 'members' ) ); // array of post types to include


add_action( 'pre_get_posts', 'include_custom_posts_in_search' );