You want to use the newer meta_query methodology…
You establish a meta_query and then use arrays for the different conditions you want met, preface them with the relationship relation => 'AND' or relation => 'OR'
$loop3 = new WP_Query( array(
'posts_per_page' => 10000,
'post_type' => 'volunteers',
'meta_query' => array(
'relation' = 'AND',
array(
'key' => 'state',
'value' => $stateselect,
'compare' => '=',
),
array(
'key' => 'volunteer_type',
'value' => 'painter',
'compare' => '=',
),
),
) );
Codex has a write-up here:
https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters
Note
That’s a lot, like A LOT, of posts_per_page.
Related Posts:
- Best Practice for PHP
- Include WP_Query in my own PHP file?
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- Display certain amount of posts on taxonomy archive page
- Result of Custom WP_Query appears on 404 Page (but result are found!)
- Show only one post for each author ( Page loads too slow )
- how to display active, upcoming and past event with featured listing with pagination
- Get list of WP Updates Across Sites
- what is diference wp_get_attachment_url / wp_get_attachment_src / get_post_thumbnail_id?
- Modern Tribe Calendar wp-query with meta query not working at all
- if statement on database query
- WP_Query sort using multiple numeric meta values
- WordPress WP_Query() Not working properly
- How to get to a specific position in wp_query?
- Get category name from custom loop and echo it once
- API response to be stored locally
- WP_Query loop, does not display special characters in title correctly
- Remove query string specific key value
- Hide post if matches current month and year
- Use WP_Query in shortcode
- How to filter posts by post format “standard” from wp-json api?
- Why is variable not working on custom sql query using wpdb?
- Random order of WP_Query results with highest meta value
- Using foreach loop breaks
- Dynamic content based on a URL parameter
- Get users that likes the post
- inserting a post from an extern php file but post content doesn’t show on wp site
- WP_Query fails despite having 1 post
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- Why doesn’t PhotoSmash plugin play well with wp_query?
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- change the default order of posts only for specific categories
- Getting posts to exclude from array
- Custom post type permalinks do not appear using the link functions
- extract serialized array to use for wp-query
- How can I split my query result in 2 arrays?
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- How do I check if there is a tag in the title
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- Let current user know pending posts counts using wp_query
- get_terms with specific id order
- WP_Query for woocommerce products with a pattern as a post_title
- “pre_get_posts” orderby custom date field in different format?
- WordPress Search Ajax + Isotope + InfiniteScroll
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Replace a single variable with add_filter
- How to exclude meta no index pages from wp_list_pages
- meta_query search names when they have middle initials
- How to call my PHP function with AJAX ? wp_query
- Ajax filter with loadmore button
- Query by pagename not Working
- Display featured image of post type category
- Delete post meta by serialized meta value
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Getting info about selected posts using one WP_Query
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- WP_Query To Display Product Of Brand On Taxonomy Page
- How to display last whole post on the homepage
- Query to show average # of months all accounts with specific role have been active
- Query doesn’t display text data with apostrophes
- How to return count of items found in SQL query
- wp_query beginner
- SQL Query Search page
- For each 3 posts, show a different post type
- insert thumbnail image from php script
- WooCommerce – Print Processing orders [closed]
- Masonry layout within the loop
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Query category-specific, paginated posts and allow viewer to change sort order
- wordpress is_main_query() breaks
- allow previews outside wordpress folder (Outsourcing WP previews)
- How to get category pages to look like a certain archive page?
- Post Title Not showing up
- Advanced Taxonomy query, with 3 post types
- reorder a WP_Query, using a dropdown
- Custom query_posts() parameter
- Why does a meta_query break this WP_Query?
- How to modify this function to exclude also the post belonging to a specific category?
- Display biography post for today’s birthday person
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Three different queries on same page
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to sort search result by post_title, then by post_content
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- How to show correct td of table tags in wp_query loop
- Show post in elementor based on views and specific category with query id feature in elementor