Why is this query not working? (Standard posts + custom post type)
Why is this query not working? (Standard posts + custom post type)
Why is this query not working? (Standard posts + custom post type)
Rather than trying to find postmeta that matches (postmeta queries are typically very slow), it sounds like you would do better to work with Custom Post Types and Taxonomies. “Organization” would be a custom post type. Any people you may want to reference differently, like your examples of “Advisor” and “Team Member,” would work as … Read more
I had the same desire. A quick and dirty answer is to use the get_meta_sql to replace the leading ‘AND’ with an ‘OR’. (See also the answer here: https://stackoverflow.com/questions/43734845/how-to-give-or-relation-in-tax-query-and-meta-query-wordpress ( A related, but not duplicate, question.) )
well you meta_query excludes all the non xyz results, so you would have to adapt that part, that it also includes all the other ones. in the example bellow, the query calls for xyz and for those, who dont have that field set at all. resulting in 3 meta queries, one for price, one for … Read more
You’ve already named the clauses in your meta query, so you can reference these directly in the orderby argument: $query->set( ‘orderby’, array( ‘enddate’ => ‘DESC’, ‘startdate’ => ‘DESC’ ) );
OK, so that’s a little example of what I call “wishful coding” 😉 get_terms(array( ‘taxonomy’ => ‘property-status’, ‘value’ => array(‘For Rent’, ‘Arrendamento’), ‘compare’ => ‘IN’, ) ) You use get_terms function here, which will Retrieve the terms in a given taxonomy or list of taxonomies. And you use this inside of meta_query part of a … Read more
Your code looks correct. Have you checked your stored meta data to confirm the value stored is 1? Also, have you tried comparing to a string value, eg ‘1’ instead of 1? Just a stab in the dark, but worth a shot. Assuming your stored values are correct, and seeing as the values can only … Read more
How does one perform a sub query with different post types
Extend product search with meta in WooCommerce
In answering my own question I have decide to go the pure SQL query route as WP runs too many queries in fetching a post and its attached post thumbnail, in addition to fetching and building meta for that thumbnail. Here is the code I ended up with: $query2 = “SELECT post.ID, post.post_title, thumbnail_url.meta_value as … Read more