In the WP Docs you can find the answer.
I have not tested this snippet, but it should become something like this:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'product-ean',
'value' => 123,
'compare' => '=',
),
array(
'key' => 'item-ean',
'value' => 123,
'compare' => '=',
),
),
);
$query = new WP_Query( $args );
Related Posts:
- Using Query Posts With Multiple Post Types And A Taxonomy
- Can’t sort order of wp_query with 2 meta keys
- Display custom post type from dynamic custom field
- Get posts between custom dates
- find custom post type post by searching its custom field with my string
- WP_Query of custom post type sorted by meta_key has unexpected results
- WP_Meta_Query object with conditionals
- WordPress custom post type
- Custom Query With Multiple Meta Key Value
- Querying meta values within an array
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- wp_query check if integer exists in custom field’s array
- Get latest 3 posts from multiple CPT in one query
- Fetch Record based on meta key dates
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- how to make members list directory through wordpress post custom meta key.
- Why is this query not working? (Standard posts + custom post type)
- Polylang non-default language ignores tags in WP_Query
- WordPress request fiter order by related post’s post_title
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Different Ways to Query Custom Post Types?
- Possible to filter custom post type with multiple meta data?
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- How to display Related Posts based on number of taxonomy terms matched
- Filter date from post meta when date is in string format
- How to make WP_Query not to show irrelevant posts?
- Loop for custom post types filtered by a taxonomy
- Displaying a div from an assigned meta_value when on a page
- WP_query – Filter by tax_query and meta_query using multiple select
- How to get specific post meta by title or id
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Getting a custom post’s custom field based on another custom post’s custom field select
- Querying multiple values from a single key
- Pagination not working on custom query on a page
- FacetWP paging custom wp_query
- $post->post_meta not pulling any post in wordpress/php
- Returning a custom content types with meta values
- Can’t change posts per page in WordPress Post Type Query
- postsperpage value not being applied
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Query Posts, order by meta value
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- HM CMB: Post Select Field for CPT ID
- Custom Post Type Query W/Category Dropdown
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Sorting the Loop by Taxonomy Value
- Custom Query: Multiple CPTs and a taxonomy filter
- WP query_posts group by meta field related
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Custom wp-query display post only today
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- How do i create a custom post query when the meta value is an array?
- custom post type and a “sticky” position taxonomy
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- meta query condition don’t work
- Custom query result empty on page 2
- How to sort by multiple values in a nested WP_Query
- Show posts from WP Custom Post Type selected from a field in a metabox
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- How to get post by meta value
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Linking posts together with Advanced Custom Fields “both ways”
- Query the title of the page to show posts with matching category in the loop
- Not able to get my custom search result using meta_query and tax_query together?
- update a posts of other custom post type
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- Querying, storing, and using data from 2 separate custom post types
- get_post_meta for Custom Post Type ( CPT )
- Main site single-property.php design, as homepage of a multisite
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Imported Content Doesnt Show Up On Frontend
- meta query always fails even if data is correct
- display news with pictures 3 small and one large (loop)
- Selecting posts older than the current Unix epoch timestamp
- Custom Post Type meta oembed html output resulting in WSoD
- Filter RSS feed for custom post type to events for next 7 days only
- Values inside a custom field to determine which category posts to display
- Custom post type blog pagination conflict
- Query Posts From Multiple Post Types
- Trying to combine multiple WordPress queries
- Return only custom post types for the page, not all