pre_get_posts Remove tax_query Completely

This fixed it! 🙂 Hat-tip gmazzap for the useful info: Obliterate the main query and replace it function wpse_286813_omit_all( $query_vars ){ // triggered also in admin pages if ( is_admin() ) return $query_vars; if( !empty($query_vars[‘taxo’]) && $query_vars[‘taxo’] === ‘all’ ){ $query_vars[‘taxo’]=”; } return $query_vars; } add_filter( ‘request’, ‘wpse_286813_omit_all’ );

Custom taxonomy query not working with switch_to_blog

I find the solution: Tax_query not working on multisite (I dont say, that I work with switch_to_blog, because everything is works fine with this function… everything, including postmeta queries, category__not_in, etc., but EXCEPT: tax_query) So, “you have to register that custom taxonomy in both blogs”. <– so the problem originate from the different themes, when … Read more

Get list of terms that have posts in another term

Try replacing ‘operator’ => ‘AND’ with ‘relation’=>’AND’ Updated Code Snippet: $current_color = get_queried_object_id(); $query = new WP_Query( array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( ‘relation’ => ‘AND’ array( ‘taxonomy’ => ‘pa_color’, ‘field’ => ‘term_id’, ‘terms’ => $current_color, ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ … Read more

How to add autocomplete to custom taxonomy for CPT

The logic in the tax query is very unlikely to verify true. Look at it: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘zip_code’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), array( ‘taxonomy’ => ‘city_served’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), ), If you read the tax query, it … Read more

Use both meta query and tax query

Would you believe it, as soon as I posted this I remembered I asked a question about a query last year. I had a look over it and I’ve adapted my new query like so: $category_slug = filter_input( INPUT_GET, ‘eventtype’, FILTER_SANITIZE_STRING ); $cat_query = []; if( $event_type ){ $cat_query = [ [ ‘taxonomy’ => ‘eventtype’, … Read more

tax_query returning all posts instead of selective posts in WP_Query

Taxonomy Parameters Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays). This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy arrays. In ‘tax_query’ you should add array of arrays (see … Read more

How can i simulate “taxonomy__in” in query?

You can’t, because of the way categories and general taxonomies operate. Categories are a type of taxonomy, so we are querying one level lower when querying for categories. When you query for category__in => array() it actually looks up what category_terms are queried and queries posts from all those categories. Now this effect we can … Read more

pre_get_posts Tax Query not working for custom author page

Don’t run a new query in the template, modify the main query before it’s run via the pre_get_posts action in the theme’s functions.php file. function wpd_author_query( $query ) { if ( $query->is_author() && $query->is_main_query() ) { // your code to set $current_user_name here $query->set( ‘meta_key’, ‘_writer_relation_added_date_’ . $current_user_name ); $query->set( ‘orderby’, ‘meta_value_num’ ); $tax_query = … Read more

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