This should do it. The default relation is AND so that won’t need to be specified.
$args = array(
'post_type' => 'wpse_cpt',
'meta_query' => array(
array(
'key' => 'post_code',
'value' => '432C',
),
array(
'key' => 'location',
'value' => 'XYZ',
),
),
);
$query = new WP_Query( $args );
Related Posts:
- Query all posts where a meta key does not exist
- Meta query with boolean true/false value
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Can’t sort order of wp_query with 2 meta keys
- Query for posts from any post type but only add instock products
- WordPress Orderby Numeric Value Not Working
- orderby in custom WP Query does not work
- Display custom post type from dynamic custom field
- WordPress request fiter order by related post’s post_title
- Displaying a div from an assigned meta_value when on a page
- How to get specific post meta by title or id
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- Returning a custom content types with meta values
- WP_Meta_Query object with conditionals
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- 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
- Use WP_query to match post types based on custom field values
- How to sort by multiple values in a nested WP_Query
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- Linking posts together with Advanced Custom Fields “both ways”
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- get_post_meta for Custom Post Type ( CPT )
- WordPress custom post type
- Custom Post Type meta oembed html output resulting in WSoD
- Values inside a custom field to determine which category posts to display
- Querying meta values within an array
- How to use a custom post type archive as front page?
- How to display only top level posts in loop via WP_Query?
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Related posts by author pagination not working on the production site
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- custom post type paging not working past page 3
- Custom post type category not displaying in custom post type
- Query for custom posts with a specific tag slug
- How to make custom post meta wp_editor translatable?
- update_post_meta() whenever custom post type is updated
- How to best delete orphan wp_postmeta
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Replace title column in post list with post meta value
- How to add pagination to wp_query [duplicate]
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Show one item per category of a custom post type
- Storing posts from query and accessing later via AJAX call
- Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Show only one post on custom post type archive
- Pagination issue on category.php using custom post type query
- First custom field value (out of several) displayed twice after query
- How to get all tags of a custom post type by id
- Show future events based on custom field AND order by date
- How to make WP_Query not to show irrelevant posts?
- WP_query – Filter by tax_query and meta_query using multiple select
- Issue on Working with Metabox – Checkbox to enable Sale Items
- Why do I have to press the “Update” button twice to save my meta box values?
- Create a list of recent Custom Post Types posts
- Empty search input does not return all posts
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Get current user id
- List latest post out of 2 custom post types
- How to call a post’s metadata in shortcode.php?
- How to properly use Categories with Custom Post Types
- updating one custom meta field only
- Custom Post Type Query W/Category Dropdown
- Pin posts to top of custom loop
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- Foreach result into WP_query
- Query custom post type and custom field by URL parameters
- Peepso: Add extra data field (custom post meta) to postbox
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Query posts based on user preferences
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- How to use costum database table for custom post type
- Querying, storing, and using data from 2 separate custom post types
- date_query won’t accept day parameter, but will accept month and year for a custom post
- How can I use WP_Query argument ‘Like %..%’?
- Edit post meta direct from post.php?
- Custom Post ‘Post Per Page’ Crashing Page?
- Query child posts on parents single.php?
- Paged within a custom content type template [duplicate]
- Custom Post Query Combined with Conditional Tags
- Custom loop won’t work, can’t find problem
- Query by post type or category
- Custom post type – update_meta not working
- Customising wordpress search and using $_GET[“s”]
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- How to exclude certain portfolios from a loop
- show the most recent date of all posts to display on front end
- Can I add a wordpress page using the slug for a CPT rewrite