Your basic query logic looks fine assuming you want an AND
relationship between the first, middle, and last names but query_posts
is never, ever, ever the right way to do anything.
Note: This function isn’t meant to be used by plugins or themes. As
explained later, there are better, more performant options to alter
the main query. query_posts() is overly simplistic and problematic way
to modify main query of a page by replacing it with new instance of
the query. It is inefficient (re-runs SQL queries) and will outright
fail in some circumstances (especially often when dealing with posts
pagination). Any modern WP code should use more reliable methods, like
making use of pre_get_posts hook, for this purpose.
Create a new WP_Query
object and use that instead.
$args = array(
// your arguments as above
);
$q = new WP_Query($args);
if ($q->have_posts()) {
while ($q->have_posts()) {
$q->the_post();
the_title(); // etc.
}
}
Related Posts:
- Extending the search context in the admin list post screen
- what is the correct way to compare dates in a WP query_posts meta_query
- Advanced search form with filters for custom taxonomies and custom fields
- Using meta_query, how can i filter by a custom field and order by another one?
- Return all custom meta data for one custom post type
- How can I change the admin search posts fields?
- How to filter custom posts by tags and custom fields?
- Development of a WordPress Search Plugin – Best Practices
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- Search that will look in custom field, post title and post content
- Display Custom Post Type Fields
- Search everything (posts, pages, tags, cpt, meta)
- How to hook get_terms() to only show count of posts that have custom meta
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- order by meta_value serialized array
- Backend search; include CPT meta?
- Display custom post types with custom date field value (before today) & order by custom date field
- Search Custom Post Type Custom Fields
- Custom Fields vs Separate Table
- How to insert content from another Custom Post type into Post?
- Including Custom Meta with posts_where query
- search also in taxonomy, tags and custom fields
- How to stick custom post at the top in search results
- Filter custom posts using auto populated dropdown selectors
- Including metaboxes from custom post types in global search — continued
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- BBPress Search results in WordPress search
- Displaying and searching Custom Posts
- Searching Custom Fields
- filter search custom field query
- How to let users choose where to search for posts?
- Add custom attributes to a post
- Custom Taxonomy Search result page
- find custom post type post by searching its custom field with my string
- search custom post type by custom fields on front end
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Filtering custom posts by custom fields (ACF) [closed]
- Incorrect ordering of custom post type based on time
- Search CPT Title AND Meta
- Display Posts Query with IF function
- WP query_posts group by meta field related
- Create a post automatically if search result has zero results
- Advanced search form with multiple custom fields
- Search facility with directories
- Search form to find custom meta box generated data
- Query Distinct Taxonomies of Custom Post Type
- Custom post type blog pagination conflict
- Is it good practice to search for custom posts based on custom field values?
- Advanced search form with filters for custom taxonomies and custom fields
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Display ACF object field data using Elementor Custom Query
- WordPress 4.4+ : How to revision CPT + metadata
- Querying custom posts and regular posts
- Detect meta value changes when post is updated (post_updated)
- How to select one major category (or custom taxonomy) for a custom post type?
- Using Query Posts With Multiple Post Types And A Taxonomy
- Display posts if a custom field value is equal to another custom field value
- ‘category__and’ for custom taxonomy?
- Custom field default value with counter
- How to use custom fields to enable sticky posts on custom post types?
- Check if a specific custom field exists?
- Using several custom fields as custom post title
- Calculate all custom field values in the post loop
- Role scoping for contributors down to the field level
- Having unique constraints for custom fields in a custom post type
- Make parts of your wordpress website completely built with data from external APIs?
- Display custom fields from custom posts in RSS feed
- Limit Search to Post Type With Apostrophe return search not found
- Add post meta programmatically to attachment
- List of users that clicked a ‘Join’ button at single post
- Get Specific Template Part if Custom Field is Some Value
- 3 random images from custom post type, each in a div with a diffrent class
- Inserting custom fields into single.php
- How to copy a custom field from the user’s CPT to the user’s normal posts
- Make a custom column sortable by a value from a different custom post type
- Automatically add a character to field in edit post page
- Change Post Meta via AJAX from the posts list table
- Query for bbPress replies to current topic?
- Mandatory field in Custom post
- How to store the third party script with HTML code in the wordpress custom input field?
- How To Read Read Custom Post Type Data in Headless CMS Mode
- Filter custom post type admin list by custom meta column, where the column is another custom posts meta value
- How to display custom field in product description?
- Add custom template ‘sub-page’ to Custom Post type?
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- post_type incorrect for custom post type
- Live search by custom tag
- how to create custom taxonomy drop downs for parents and child
- one get_posts to return a number of custom posts for each meta value
- Using $seed on a custom post type for randomly displayed posts
- Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
- Get result from Custom Field in Custom Post type
- What’s the best way to show custom post types? With page template it’s not perfect!
- How do I do this?: If custom post type exists, echo it, else do not
- How to get lowest price from custom fields of posts
- Post object GUID adding http:/