Fortunately, this complicated database query is no longer needed. WordPress 4.1 added the ability to make complex nested meta queries which is exactly the thing I was trying to accomplish.
Here is the Trac ticket with the feature: https://core.trac.wordpress.org/ticket/29642
Related Posts:
- WP_Query Performance Issues with meta_query
- Get the post permalink within the loop but without additional DB query
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Is it possible to query from external database? [duplicate]
- How to set up hierarchical relationships without using plugins / meta query
- How to get meta key list efficiently?
- wpdb get_results() returns only 2 rows
- WP_Query always returning the last custom post
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query vs get_posts
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- What is the most efficient way of querying posts based on visits and date for current day?
- Get posts by menu ID
- When should you use wp_reset_postdata vs wp_reset_query?
- Order posts by tags count?
- Add and in the header while looping over custom query in page template
- Which custom query am I in and how can I access its properties & methods?
- How to speed up wp_query, took more 5s to run against 100k posts
- Filter WordPress posts by between parameter
- How do you query wordpress posts using a math formula between multiple meta field values?
- Custom Post order for homepage
- Get image of latest post from taxonomies/categories
- Page navigation doesn’t show when query category
- Undefined WP_Query::has_posts()?
- Is it possible to dynamically get queried term AND taxonomy?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pull post meta with post_query?
- How to access a query twice in different template files?
- Minimize database queries to user tables?
- Query all published post AND attachment with specific mime type
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Get all products which have both product category
- unable to retrive parent page information
- How to display user order by role
- How to use the query hook/filter?
- WP Query related posts by tags
- Order by summing multiple values
- Order by empty custom field
- Check if loop has any categories?
- WP_Query orderby and tax_query
- How to access custom WordPress database tables
- Query only the posts with a post format of “audio”
- pre_get_posts – Trying to get property of non-object warning
- WordPress query posts with multiple post_meta data
- how to get Nearby zipcode
- Yoast primary category query modification
- Update query for wp_posts and wp_postmeta
- Slow Query On Search
- WP_Query with page_ids in arguments without a result
- Write WP Query that selects posts that are part of the same two categories
- WP_User_Query orderby meta_val_num
- Include one page/post into query which is already returning posts
- Insert images into wordpress post with a query
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Filter products on category AND tag
- Why last row deleted when refresh page
- pre_user_query vs pre_get_posts
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Query a database based on form input then output to another page [closed]
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- How to extend WP_query to a specific table?
- Why pagination is not working with tax_query param?
- update_post_meta performance in a loop woocommerce
- WP_Query & Duplicate entries
- Add to search posts query array with post IDS which will appear first
- Query by meta value (add a dropdown of all values)
- Separate by Category Post Type
- How to show terms from another taxonomy
- I removed the “wp_rm_logs” table and am constantly getting this error
- My entry results are not consistently alphabetized
- Ignoring ‘a’ when sorting posts
- Include post_status check within $wpdb query
- Custom query for tag and custom tag from 2 post type
- Query posts in current category but not attachment format
- WP_Query secondary query failing
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- add_query_vars does not work
- Pagination not working with WP_Query (creates links but no page)
- Query custom post type by date field only working when two posts match the query
- Divide WP_Query posts by date & post type
- Retrieve posts in custom post type and specific taxonomies
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- New WordPress WP Query using posts from certain categories
- Get the number of rows from $wpdb->get_results not working
- Get Child Custom Post Content on Single.php?
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- Pre_get_post on CPT archive page
- Get posts that were most recently tagged
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- How to get posts that have certain meta key value and order based on another meta key’s value
- Filtering custom post type list in admin by custom meta key/value