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
- 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
- Display recent posts from the same category as current post in sidebar
- All-in-One Event Calendar: Custom Query – Getting each event Instance [closed]
- Counting number of posts with Category B in Category A
- Use Transient API to cache queries for all posts in all categories?
- Highlighting Sub topic in a post?
- Pagination Not working on Home Page with 2 Query
- Multiple keyword search
- 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 order by date in meta_value
- get complex results set according to category structure
- Searching through different categories on different pages code is not working
- 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
- How can you get first post, last post and post count in a category?
- How to loop for every result found in the_content() when using the search query?
- List of the years with posts presented
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- Order By table field comment_status in WordPress > 4.0
- How to optimize multiple WP_Query() calls on one page?
- Use post object from first query in second query
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- category query for pages not working
- Can we return all category (not post) with Custom Query Filter? [closed]
- Query to get siblings and parent page
- Query posts from category A, and from either category B or C
- Combining categories (Query posts with multiple taxonomy terms)
- Filtering out child category posts from parent category archive not working
- 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)
- Redirect to another page using contact form 7? [closed]
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Include posts from some categories while excluding from others
- Hide products in uncategorized category from search results
- How to order posts on each different category?
- How to load a script code only in posts?
- How to echo woocommerce category name
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How order posts from category by date and comment count?
- Get the child category ID of current category
- How to get posts by category and by choosing a taxonomy term?
- Related Posts Excluding Certain Categories
- Getting the permalink to the latest post from a category
- What is wrong with my WP_Query Arguments?
- Orderby two meta fields not working
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- Adding pagination to sub-wp_query within a singular post page
- Where is this query?
- 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`
- Use get_cat_ID to retreive multiple category IDs
- Function the_posts_pagination() not compatible with WP_Query arguments
- adding pagination to a foreach loop in wordpress
- 3 posts from each existing category on one page
- How to display the category dropdown auto search list when key press?
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- Get categories within specific term
- How to show specify category template for both parent and child category
- Display the search results like the original pages
- Exclude parent categories from recent posts list
- 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
- 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
- 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
- Retrieving category pages from subcategory returns empty sets
- Display Count of posts
- Display post list within category list sorted by name [duplicate]
- Get the type of an advanced custom field (ACF) in a WP_Query loop [closed]
- 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
- List categories using WP_Query
- Advanced Search – Is this possible?
- 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
- How could i add username field in WooCommerce