Combine tax_query and meta_query in WP_Query
Combine tax_query and meta_query in WP_Query
Combine tax_query and meta_query in WP_Query
Try this again removing operator and relation arguments as follows: here is a useful link http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/ $products = get_posts(array( ‘post_type’ => ‘products’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘collection’, ‘field’ => ‘slug’, ‘terms’ => array($current_collection) ), array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => array($current_type) ), array( ‘taxonomy’ … Read more
Never user query_posts, under any circumstances. Use WP_Query instead, which is how query_posts works internally, but without the trickery and downsides. You’ll also find that the WP_Query documentation gives you explanations for every parameter, including what you are trying to do: posts_per_page (int) – number of post to show per page (available with Version 2.1, … Read more
I’m afraid that there is no way to do such advanced queries using WP_Query. But, of course, you can still achieve that result, but you’ll need to write a little bit more code. There are two solutions: It’s hard to give you precise code, because there aren’t many details in your question, but maybe this … Read more
Well it seems after digging in to the code, tax_query is being blocked on single post/page pages which is why I’m running in to this issue. If you see the ability to run tax_query in all circumstances as beneficial, please voice your opinion on trac. See ticket here: http://core.trac.wordpress.org/ticket/24819 I managed to get around this … Read more
Terms with more than one occurrence have current-menu-item class in menu
The issue is you are overriding the entire tax_query. When you go to the UK category archive, tax query is set to have the same thing you have for International, but you are nuking the current query. Here is the solution: … $tax_query = $query->get(‘tax_query’); $tax_query[‘relation’] = ‘OR’; // puts the item at the beginning … Read more
I found out that in order to query wp posts via custom taxonomy, from a blog 1 to another blog 2, you have to register that custom taxonomy in both blogs, otherwhise it won’t work. this is strange but true! anyways it works fine now.
You can try using $wpdb, like this: // Use the global variable $wpdb; global $wpdb; // :: Define SQL command :: // You can request for the IDs only, // and then get the properties later on via get_post_meta or WC_Product() $q = ‘SELECT wp_posts.ID ‘; $q .= ‘FROM wp_posts ‘; // Attach wp_postmeta table … Read more
This is a really interesting question, which can result in a very expensive, resource intensive process which can really slow your page down dramatically PRELUDE All my code in this question is based on the following post type and taxonomy, so before you run any code, make sure to adjust the post type and taxonomy … Read more