Tax_Query using WP_Query not working

You aren’t looping through the results. Here is your code: $m = new WP_Query( $myquery ); if ( $m->have_posts() ) : $m->the_post();?> <ul><li <?php post_class();?>><a href=”https://wordpress.stackexchange.com/questions/83409/<?php the_permalink(); ?>”><?php the_title(); ?></a></li></ul> <?php endif; wp_reset_postdata(); ?> There is no Loop. You just check for the existence of posts, echo some information about the first one and quit. … Read more

Exclude post type with pre_get_posts?

I found a solution to this myself. It returns the default post type posts instead of excluding the custom post type which is fine for my needs. function my_breakfast_query ( $query ) { // not an admin page and is the main query if (!is_admin() && $query->is_main_query()){ if (is_tax( ‘food’, ‘breakfast’ )){ $tax_query = array( … Read more

how to use tax_query to apply both terms or one if one is empty

Change your code with the following: $args = array( ‘post_type’ => ‘property’, ‘posts_per_page’ => 5000, ); $statuses = explode( ‘,’, $st_term_final_string); $terms = explode( ‘,’, $il_term_final_string ); if ( $statuses || $terms ) { $args[‘tax_query’] = array(); if ( $statuses ) { $args[‘tax_query’][] = array( ‘taxonomy’ => ‘Status’, ‘field’ => ‘slug’, ‘terms’ => $statuses ); … Read more

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