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
- Exclude or Include category ids in WP_Query
- How can I save an array from a random post sequence for later use?
- How to filter by category in REST API, excluding posts also in other category term?
- Limit search results to exact match
- How to order category.php loop by ‘meta_value’?
- How can I display recent posts from a particular category in my header?
- Multiple keyword search
- Get number of comments after modifying comment query
- Show default content if custom WP_Query has no posts
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How get posts from a subcategory of a category by name?
- $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
- 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 to show subcategories using loop?
- Sub-loop / nested loops Best Practices
- List of the years with posts presented
- Remove a specific category ID from related post
- Complex Category selection as per user input
- Show all post for a given category
- Five posts from a category in footer
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- Clean up WordPress code that repeats
- How to get all unique categories for posts in loop?
- Use post object from first query in second query
- Display Featured Post by Categories and Avoid duplicated posts
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Can we return all category (not post) with Custom Query Filter? [closed]
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Query posts intersecting tags and categories
- Cutom wp_query for geolocation search, pagination not working
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- Check if loop has any categories?
- Exclude Category filter from Portfolio section
- Include data from custom table in WP_Query
- echo a specific meta_key queried through a custom post
- WP Group posts by year(desc) > month(desc) > date(asc)
- Inserting HTML to close and open divs in WP_Query loops
- Include posts from some categories while excluding from others
- Combine results of multiple WP_Query to resemble single WP_Query
- WordPress Custom Search Form Displaying Unexpected Results
- Hide products in uncategorized category from search results
- How to order posts on each different category?
- How to echo woocommerce category name
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- Loop categories by recent post
- How order posts from category by date and comment count?
- How to get posts by category and by choosing a taxonomy term?
- Getting the permalink to the latest post from a category
- What is wrong with my WP_Query Arguments?
- Custom wp_query – I’m getting ‘all’ post, not the specific post in the query
- meta_query with array as value with multiple arrays
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- How to make a query returning pages from multiple parents
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- get_the_terms has strange result since version 6.0
- Filter sub-category from checkbox form
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Filter products on category AND tag
- adding pagination to a foreach loop in wordpress
- 3 posts from each existing category on one page
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- Related categories order posts by 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?
- Display the search results like the original pages
- 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
- Add to search posts query array with post IDS which will appear first
- 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
- display all posts from category with and without terms in chronological order
- Pull posts from all categories if quantity is not met?
- Retrieving category pages from subcategory returns empty sets
- query.php – multiple is_category functions
- Display Count of posts
- Create multiple sections for all categories and then queries all the posts for each of those categories
- 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
- query_posts problem – need help
- shortcode with $atts with strange results
- Filter posts by category
- 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