You can try this:
/**
* Add support for the "display_name" search column in WP_User_Query
*
* @see http://wordpress.stackexchange.com/a/166369/26350
*/
add_filter( 'user_search_columns', function( $search_columns ) {
$search_columns[] = 'display_name';
return $search_columns;
} );
where we use the user_search_columns
filter to modify the available search columns.
So what fields can we use with this filter? Here’s the list of all the fields in the wp_users
table:
x ID
x user_login
user_pass
x user_nicename
x user_email
x user_url
user_registered
user_activation_key
user_status
display_name
where I’ve marked the default search columns with an x
.
Related Posts:
- How to order WP_User_Query results to match the order of an array of user IDs?
- How to get user by display_name with WP_User_Query
- Two queries for a WP_User_Query search work perfectly apart, but not together
- the_date() not working
- Query multiple custom post types in single loop
- The correct method to pass query vars in AJAX using ajaxurl
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- Alter query on edit.php
- What is the most efficient way to search users by their display name?
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- How to order posts by modified date without using ‘query_posts’?
- Delete post revisions on post publish
- How to sort results from a custom database table
- Specific Loop For 2 Within Each
- How to get a list of all users registered before a given date?
- WP database error for comments_popup_link()
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- WP_User_Query order by meta_key that is an array
- Use two WP Query in template
- my function doesn’t return my post from today
- Display related products with custom output
- Get ID of child from child slug, while knowing parent ID
- List User order by ID in Descending order (Backend)
- spliting posts into two columns
- How to get to a specific position in wp_query?
- WordPress – query 5 posts with a specific post in top
- Multiple choice in a custom taxonomy
- Get all user meta by meta key instead of ID
- Why is variable not working on custom sql query using wpdb?
- How to get a list of all possible values of a specific user meta key?
- Get stock by custom meta field on all Woocommerce variable products
- Any possible way to make $wpdb->get_results() return anything else than array?
- Custom filter in admin edit custom post type responding with invalid post type?
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- mysql query from wordpress page using custom table
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- Set WP_query ‘order’ option by another tables value
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Increase offset while looping
- Get users that likes the post
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- How to pre populate a form field with a link of a current user’s author profile?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- register_taxonomy() take much queries
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- Odd / Even posts add class minus first post
- unable to use ‘new WP_Query’ in AJAX call
- Normal PHP array for exclude section of WordPress query?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to list commenters and days since last commented
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- working with term_relationships table
- WordPress query undefined offset in loop
- Can I make get_users() query global?
- Issue with custom loop in Archive page
- How to display SQL query that ran in WC_Order_Query?
- Custom Post type slider with thumbnail navigation
- Parse error: syntax error, unexpected ‘}’ [closed]
- Shortcode to pull posts
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- How do I remove duplicate users from two merged WP_User_Query objects?
- WordPress PHP syntax doesn’t seem to be working correctly
- Querying for specific tags
- How to get thumbnail with pure PHP in a WordPress database?
- Limit tags shown in post
- Why my query does not run with prepare
- mySQL queries are executed twice on wordpress website
- List of Events with Multiple Dates: Only NEXT Date
- Echo array value
- Undefined variable: row?
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Query pulling a single post per month
- WordPress Custom Query: Combining Two Functions
- SQL error with custom query
- WordPress is removing query variables like page, p from the URL of a custom static page
- WordPress Conditional / Multiple Taxonomy Query
- How can I modify this code to make the search box include tags and meta
- WordPress get last inserted user id
- Reject all malicious URL requests functions.php
- Advanced Query posts
- How can I check that the acf field value is not a duplicate when adding a post?
- Build A Custom SQL Query for WordPress Search
- My Custom Post Type AJAX Query is Returning no posts – why?