I’m little unclear from your question if the criteria has to match the Product AND the Service .. or the Product OR the Service. You can change the ‘relation’ parameter to achieve this (AND or OR)
$args = array(
'posts_per_page' => -1,
'cat' => 7,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'product_customfield',
'value' => 2,
'compare' => '=',
),
array(
'key' => 'service_customfield',
'value' => 5,
'compare' => '=',
),
),
);
$query = new WP_Query( $args );
Related Posts:
- I need to get all categories from a WP_Query
- Nested meta_query with multiple relation keys
- numberposts? showposts? posts_per_page?
- Exclude or Include category ids in WP_Query
- How to query only for products with status “in stock” in WooCommerce? [closed]
- WP_Query to show post from a category OR custom field
- get_posts with multiple categories
- ajax category filter
- How can I save an array from a random post sequence for later use?
- Display recent posts from the same category as current post in sidebar
- All-in-One Event Calendar: Custom Query – Getting each event Instance [closed]
- How to filter by category in REST API, excluding posts also in other category term?
- Is there an action/filter called when WP_Query->query is finished and assigns posts
- Counting number of posts with Category B in Category A
- Limit search results to exact match
- How to order category.php loop by ‘meta_value’?
- Use Transient API to cache queries for all posts in all categories?
- How can I display recent posts from a particular category in my header?
- Highlighting Sub topic in a post?
- Sorting Posts by custom field
- Pagination Not working on Home Page with 2 Query
- Multiple keyword search
- Get number of comments after modifying comment query
- Show default content if custom WP_Query has no posts
- WP Query with multiple categories – passing an array works?
- wp_query display posts from same category of the post
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- WP_query category__in not working, only pulls from first category
- WP_Query order by date in meta_value
- How get posts from a subcategory of a category by name?
- get complex results set according to category structure
- Include Sticky Posts with Custom Query
- Searching through different categories on different pages code is not working
- $wpdb->insert inserting two rows in database
- Get image of latest post from taxonomies/categories
- How To Remove/hide some specific categories from two different categories widget from sidebar
- How to show in search results posts with a particular tag in a particular category?
- How to select posts from one category but exclude posts in another category?
- Get Category Archive Template Name Dynamically
- WP_Query arguments to fetch custom post type posts which are in certain category?
- How do I reset this wp_list_categories query?
- Create unique page without header.php for json feed
- How can you get first post, last post and post count in a category?
- How to show specify category template for both parent and child category
- WP Query for all events prior to current date
- How to extend WP_query to a specific table?
- Pagination for Category does not work
- Display the search results like the original pages
- Exclude parent categories from recent posts list
- Display All Top Child Categories / Taxonomy
- Query post by Category and custom file (ACF)
- Check the product in the cart from which category is and show message
- WP_Query showing all posts, except from category X, unless it’s also in Y
- Multi line of $wpdb->query just run 1 time and end the loop right after
- Add to search posts query array with post IDS which will appear first
- Woocomerce – Order products by float attribute in archive pages
- Single query for multiple categories
- Display 3 levels of categories on page
- Filtering ‘Featured’ posts from a batch of category IDs
- Show posts from categories instead of tags
- How to exclude posts by ID within a category/archive loop
- I have 3 categories, i want to display on a loop the last 3 of every category
- Adding Category in WP_Query Not Working
- How to set up pagination for a custom loop on a global template (author.php, tag.php, archive.php?)
- display all posts from category with and without terms in chronological order
- Help displaying related categories
- Pull posts from all categories if quantity is not met?
- Custom query using WP_Query is not working
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Category Archive not working for pages
- Show full category tree for a year with all post titles?
- Retrieving category pages from subcategory returns empty sets
- query.php – multiple is_category functions
- Display Count of posts
- Display post list within category list sorted by name [duplicate]
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Limit the number of posts from a specific category on index.php
- Get the type of an advanced custom field (ACF) in a WP_Query loop [closed]
- Switched from query_posts to wp_query, pagination no longer working
- WP_Query breaks pagination
- Pagination problem with multiple loops on the same page
- query_posts problem – need help
- Related posts with WP_Query
- Main loop querying current template’s info only in custom category archive pages, not my posts
- shortcode with $atts with strange results
- Filter posts by category
- query_vars category_name only display one catgory out of multiple categories
- List categories using WP_Query
- Advanced Search – Is this possible?
- How to get post taxonomy url and name in wp_query
- Pagination only showed when no category is set in wp_query
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2
- Excluding a category from frontpage but not from WP_Query
- $wp_query->found_posts; returns zero
- Rewrite URL custom search query
- why same category base and single post base don’t work?
- Query for posts belonging to multiple categories
- How do I show related posts from categories instead of tags?
- How to remove “MY WORDPRESS”” Label
- How could i add username field in WooCommerce