Search Multiple Fields
-
So I’ve added the following code to my functions.php which limits the search bar to ONLY look at last_name. But I’d like to expand it to include first_name and phone_number. How do I let the search bar cover those additional fields?
function kia_meta_search( $args ){ // this $_GET is the name field of the custom input in search-author.php $search = ( isset($_GET['as']) ) ? sanitize_text_field($_GET['as']) : false ; if ( $search ){ // if your shortcode has a 'role' parameter defined it will be maintained // unless you choose to unset the role parameter by uncommenting the following // unset( $args['role'] ); $args['meta_key'] = 'last_name'; $args['meta_value'] = $search; $args['meta_compare'] = '='; // need to unset the original search args if( isset( $args['search'] ) ) unset($args['search']); } return $args; } add_filter('sul_user_query_args', 'kia_meta_search');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Search Multiple Fields’ is closed to new replies.