By default, WordPress search only looks through posts and pages — user profiles are stored separately and never appear in search results, even if a visitor’s name matches the search term exactly. To include users, you need to run a separate WP_User_Query alongside the normal search and merge the two result sets yourself, since WordPress users aren’t stored as posts, so posts and users can’t be searched together in a single query.
Why Default Search Skips Users
WordPress’s core search (WP_Query with the s parameter) only queries the wp_posts table. User accounts live in wp_users and wp_usermeta, which are entirely separate database tables with their own query class. That structural separation is why a plugin or custom code is required — there’s no built-in setting to toggle.
Querying Users Alongside Posts
The standard approach is to intercept the search request, run your normal post query, then run a second query using WP_User_Query with the same search term, and combine both into the results your theme displays.
function get_matching_users( $search_term ) {
$user_query = new WP_User_Query( array(
'search' => '*' . esc_attr( $search_term ) . '*',
'search_columns' => array( 'user_login', 'user_email', 'user_nicename', 'display_name' ),
) );
return $user_query->get_results();
}
The search_columns argument controls which user fields get matched. By default WordPress only checks user_login, so a custom field search — like eye color or job title — requires building a meta_query on top of WP_User_Query rather than relying on the plain search parameter alone.
Searching Custom User Fields
If you’re storing extra profile data as user meta (job title, department, location, ACF fields), add a meta_query to the same WP_User_Query call:
$user_query = new WP_User_Query( array(
'search' => '*' . esc_attr( $search_term ) . '*',
'meta_query' => array(
array(
'key' => 'job_category',
'value' => $search_term,
'compare' => 'LIKE',
),
),
) );
One quirk to know: combining a meta_query with a keyword search in WP_User_Query returns only users matching both conditions together, even when the meta_query uses an OR relation — you can’t treat the keyword search and the meta filter as independent alternatives without extra filtering on the pre_user_query hook.
Merging Users Into the Search Results Page
Once you have both result sets, combine them in search.php (or wherever your theme renders search output). Since posts and users have different data structures, you’ll typically loop over each set separately rather than force them into one identical format:
<?php
$search_term = get_search_query();
// Regular post/page search
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_title( '<h3><a href="' . get_permalink() . '">', '</a></h3>' );
endwhile;
wp_reset_postdata();
endif;
// User search
$matching_users = get_matching_users( $search_term );
if ( ! empty( $matching_users ) ) :
echo '<h2>Users</h2>';
foreach ( $matching_users as $user ) :
echo '<p><a href="' . get_author_posts_url( $user->ID ) . '">' . esc_html( $user->display_name ) . '</a></p>';
endforeach;
endif;
?>
Displaying them as a separate “Users” section avoids mismatched fields (users have no post excerpt or featured image, for instance) while still surfacing both types of content on the same results page.
Using a Plugin Instead
If you’d rather avoid custom code, plugins built for user directories — such as UsersWP or Users Insights — add searchable user listings with filtering by role, custom fields, or activity, without touching functions.php. These make more sense if you need an ongoing, admin-manageable user directory rather than a one-time tweak to the main search.
Join The Discussion
Have you built a combined search that includes users, and if so, how did you handle ranking or sorting when posts and user profiles both matched the same term?