Empty tax_query array returns an empty array

As already hinted by @Milo, check if you have terms before appending your tax_query You can try the following: (Requires PHP 5.4+ due to short array syntax, revert to old syntax if necessary) $args = [ ‘post_type’ => ‘product’, ‘posts_per_page’ => 15, ‘paged’ => $paged, ‘post__not_in’ => $exclude, ‘s’ => $filter, ]; // Append our … Read more

Is it possible to dynamically get queried term AND taxonomy?

In a taxonomy template, the queried object is an instance of WP_Term, one of whose fields will be the taxonomy the term comes from. So, you can start your taxonomy.php as follows: $queried_object = get_queried_object () ; $args = array ( ‘post_type’ => ‘inventory’, ‘tax_query’ => array ( array ( ‘taxonomy’ => $queried_object->taxonomy, ‘field’ => … Read more

How do I sort posts by custom taxonomy?

If I understand your question correctly, I think I may have your answer in this blog post: https://evowebdev.com/2017/05/using-a-dropdown-menu-to-filter-a-custom-post-type-with-custom-taxonomy/ This solution specifically uses select form element auto-populated with taxonomy terms to sort CPT posts (ie, rather than presorting posts with pre_get_posts, it lets site visitors sort by the taxonomy term[s] they select). If it’s really important … Read more

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