Meta Query relation “AND” not working

You mixed meta query and tax query It should look like this $query = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 12, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘meta_query’ => array( array( ‘key’ => ‘_stock_status’, ‘value’ => ‘instock’ ) ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_visibility’, ‘field’ => ‘name’, ‘terms’ => ‘featured’ … Read more

Query custom post type by category slug

I’ve got an answer that worked perfeclty for me in another forum, so I’ll post here if sometime anyone gets a similar problem $argsPost = array( ‘post_type’=>’album’, ‘orderby’=>’date’, ‘order’ => ‘DESC’, ‘posts_per_page’=>’4’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘albuns_categories’, ‘field’ => ‘slug’, ‘terms’ => array( ‘ANYTERM’ ), ‘operator’ => ‘IN’ ) ) ); =D

OR for a single taxonomy in a tax_query

So in the comments you said: We’re in the middle of an address system migration and this query needs to return objects where one of these matches. Either the old system (county field) is set to an id, or the address value has a match to the search word If you look at the documentation, … Read more

$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies

Do a tax-query and then count the result. No need for a custom query with dozens of JOINS. $posts = new WP_Query( array( ‘post_type’ => ‘MYPOSTTYPE’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘TAX_1’, ‘field’ => ‘slug’, ‘terms’ => array( ‘TERM_TAX_1’ ), ‘operator’ => ‘IN’ ), array( // etc. ) ), ‘post_status’ => ‘publish’ ); prinft( … Read more

in_category() and tax_query with custom post type

Instead of in_category try has_term – http://codex.wordpress.org/Function_Reference/has_term This should work (I’ve tested it in a simpler form on my localhost): <?php get_header(); ?> <div id=”body”> <div class=”fix”> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if ( has_term(‘natige’, ‘products_brand’)) :?> <div class=”col-2 nati-col”> <div class=”col-left”> <div class=”nav”> <a href=”https://wordpress.stackexchange.com/questions/137042/<?php if (ICL_LANGUAGE_CODE ==”ru’){ echo … Read more

using multiple terms in tax_query

You’re mixing up arrays. In your “my implode”, $checkedBundeslaenderList varies between a string and an array, depending on the number of items. And then in your query args, you nest it in an array: ‘terms’ => array( $checkedBundeslaenderList ), So what you could end up with is either: array( array( 1 ) ); …or: array( … Read more

How to write a Tax Query that matches all terms in an array?

I believe changing your operator to ‘AND’ like below will work: $selectedOptions = array(‘test-attribute’, ‘test3’); $args=array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘pa_filterable-attribute’, ‘terms’ => $selectedOptions, ‘field’ => ‘slug’, ‘operator’ => ‘AND’ ) ) );

tax_query: Order by slug?

If I understand your scenario, your events are in the right order but your semesters are not. If you change line 4 $terms = get_terms(‘semesters’); to $terms = get_terms(‘semesters’, array( ‘orderby’ => ‘slug’ ) ); that should put the semesters in the order you’re looking for. ‘order’ defaults to ASC, which is what you need … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)