If I understand you correctly, you need to have post metas in your query. This is where the meta_query
parameter of the WP_Query class comes to help.
The meta_query
is an array of arrays.
Example from the codex:
$args = array(
'post_type' => 'my_custom_post_type',
'meta_key' => 'age',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'age',
'value' => array(3, 4),
'compare' => 'IN',
)
)
);
$query = new WP_Query($args);
Related Posts:
- sort search results by custom fields using dropdown
- Custom search SQL Query to add custom field in result
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Search & column order by meta value in admin
- searching by keywords in post’s metas or pagination links problem
- Create custom query for search?
- How to display search query as formatted text?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Including custom fields in search?
- Add custom fields to search
- How to rename a custom field?
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- Meta Query with AND & OR?
- Custom search: by post data and post metadata?
- Need small coding with Custom Fields Search
- Search ONLY by meta key / meta values
- Filter results with custom field values and dropdown
- Add custom field (value) to search result (without plugin)
- Is there a way to do multiple ordering on a multiple meta_query?
- searching in custom meta field
- WordPress Search Custom Meta Field Only
- Exclude custom post type from search by custom field value?
- Plugin similar to Taxonomy Drill-Down for custom fields?
- Extend ‘The Events Calendar’ search to include custom fields [closed]
- Include woocommerce custom field value in front-end search result
- How do I query for a post by custom field?
- Including Database Generated Pages in Site Search [closed]
- Count how many posts have a custom field set
- Adding Custom Fields to Search
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Using a checklist to search against metadata
- How can I sort homepage by a meta value?
- Loop to display random posts only if a custom field matches category
- How do I use wp_query for WordPress search?
- Custom Fields Not in Search Results
- Conditional custom field query
- Display only past events on that page using Visual Composer Grid Bulider
- Custom Field Create Bulk via SQL Query
- Create Pop-Up Box with Custom Field Content Inside the Loop
- How make a custom search on backend in WordPress without plugin?
- query usermeta from custom field
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Advanced search for meta fields
- Merge Multiple Custom Fields into one New Custom Field for Searching
- Alter main archive, to show posts with meta as last
- How to populate custom field dropdown box based on prior selection?
- Search in Archive Pages by subcategory, tag, custom field and year
- Custom WP_Query for WordPress Search Results with meta_query
- Trying to reorder posts by custom field
- Limits, not all post are showen when querying for posts by view count
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- filter custom field values $min $max
- Restrict WordPress Search to Custom Field
- How can you include custom post meta in search without calling each key?
- Get post ids sorted by meta_key
- querying a custom field
- pre_get_posts : only get posts by wp_usermeta value
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- How to query an out put value?
- List custom queried terms in the edit-tags.php?taxonomy page
- Modify date query by URL parameter using pre_get_posts and $_GET
- Include one custom field in search results
- Loop through incrementing custom fields
- Filtering custom posts by custom fields (ACF) [closed]
- Search Results Page – Displaying Custom Meta Fields
- Custom field Search with Relavanssi
- WP_Query () using taxonomy, custom post types
- How to query for posts with either one or another custom field
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- How to show content of custom fields in search results?
- Custom Query: query by post custom meta data
- Get array of posts based on custom field values
- How to query posts by month based on date custom field?
- Custom Field Date Problem
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Compare ACF date field (if exists) and post date and order DESC
- Type character in name and make it invisble
- Problem with revisions only returning four results
- Dynamically populate query source in Elementor post widget
- search based on custom field
- Very large list of options for BuddyPress profile fields
- Search fails when using the radio buttons
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Admin – Search Events by a custom field
- Search one custom field?
- Query postmeta values, and return multiple post_titles for common meta value
- Query Custom Fields in Searchform
- Help sorting by Meta Key value
- query specific posts according their custom fields, using sql SELECT
- Meta_query not filtering posts
- Get multiple posts with some custom fields efficient
- How to add a prefix to existing custom fields over MYSQL query?
- Complex WP_Query Using Post Date And Post Meta
- Custom search with meta fields
- How to check if custom field exists in this widget query
- Only show content slideshow if “slideshow” custom field exists
- Search for meta_query does not return any result if combined with title