Check this : Get posts by meta data OR title
The first piece of code is working and allow to make a query based on meta data
You could just get rid of useless stuff (or adapt if you want to use several keys) :
$args = array(
'post_type' => 'wine'
,'meta_query' => array(
'key' => 'vintage'
,'value' => '2005'
,'compare' => '='
)
);
$query = query_posts( $args );
Related Posts:
- How to solve suspected memory issue in custom WordPress loop?
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Get_post_meta() won’t return value
- Display custom post on home page based on a metabox selection
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- How to insert content from another Custom Post type into Post?
- WP_Query orderby modified to include custom meta changes
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- Calculate all custom field values in the post loop
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- How to conditionally add Custom Post Type to Front Page
- hide specific div on single.php [closed]
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- How do you output an unknown number of images in a custom post type with desired markup?
- Get data from PHP to JavaScript to set position of each post on front page
- Get post content from another section in custom single page
- Displaying information from custom field on custom post type
- Get post-meta value of all custom-posts – lowest to highest year-count?
- Custom PT, Taxonomys and wordpress query
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- How do I list a custom field and custom taxonomies for each result in a loop?
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- when looping through custom post data not appearing
- How to avoid duplicate posts queried from custom meta?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Adding a Section for Visitors
- sorting in wp query based on custom field value
- Custom taxonomy template for custom fields loop [closed]
- Sort loop by custom field from different post type
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- WordPress loop, show only one post per custom field
- How to get past and upcoming post by defining date in custom field?
- Order by custom field attribute
- Get result from Custom Field in Custom Post type
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- loop through custom post-type with two meta_keys
- How do I filter a custom post type loop by a field?
- add_meta_box: Datepicker like the one for postdate?
- Custom field losing p tags on display
- Getting a “Changes you made will be lost” dialog prompt on a custom post type page
- Saving repeated option values in a custom query
- How to remove slug metabox from custom post type’s page?
- Remove duplicated values from a loop
- Custom fields in Permalinks?
- query posts and custom post type with meta key
- Custom Post Type Loop throws 500 error when used in widget
- WordPress Custom Fields Won’t Save
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Display Custom Taxonomy Alphabetically
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Problem: wp_query outputs all images on site
- Display related custom taxonomy posts in sidebar
- filter search custom field query
- Warning: Invalid argument supplied for foreach() [closed]
- Add additional field to custom post_type
- Conditional for a Single Post That Belongs to a Category?
- Using wp_query to modify the loop in index.php for a CPT
- Sorting posts by custom field value in array
- Listing custom post types on archive page with array
- Displaying custom fields for custom post type generate with Custom Post Type UI Plugin
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- get custom post type value in header.php [closed]
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Building a Portfolio and need some direction
- Custom Post Type Query W/Category Dropdown
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Create list from custom field comma separated values
- add_filter get array data before display in custom post_type
- On click some element i want to use some template
- Get previous and next custom post by custom field
- How to Enable Ascending or Descending In WordPress Default Built-in Loop
- Fetch data from two custom post types and create multidimensional array for output to html table
- Pin posts to top of custom loop
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- Combine multiple separate lists into one
- Show Post columns to specific users on condition
- Custom post types – meta_query: search lesson which starts sooner
- Populate custom post type/custom fields from an external database
- Custom Field to post_title
- Automatically convert standard posts with custom fields to custom post types
- How to show Y number of custom posts after every X normal posts?
- Get month and day from a Date Picker custom field
- custom fields not showing before get_header
- Display Custom Post if custom field is marked
- Query Distinct Taxonomies of Custom Post Type
- How to loop custom post type posts by author?
- Inserting random posts
- Allow authors to create article image
- How to exclude certain portfolios from a loop