Improving WP_Query performance for multiple taxonomies

I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I’m using a WP_Query like so: array( ‘tax_query’ => array( ‘relation’ => ‘OR’, array(‘taxonomy’ => ‘tax1’, ‘field’ => ‘slug’, ‘terms’ => ‘term1’), … Read more

Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy

I need help with WP custom taxonomy and custom post types. I never find a working solution so far. Please accept my apologies if this has a simple solution. I tried my best to find solution everywhere first. Explanation of issue – I have one taxonomy called “department”. I have 3 CPT called “course”, “faculty”, … Read more

tax_query shows no results if nothing is selected

I am creating a real estate website on WordPress, I am creating a custom search and am using tax_query to filter search results to display “States” & “Suburbs”. The search works fine, when options are selected. However if nothing is selected, no search results will display at all. This is a problem with a real … Read more

Custom archive page based on array of categories and tags

I’m looking to create custom archive page based on passed arrays which contains categories and tags, for an example: http://www.mydomain.com/archives-custom.php?c=cat1,cat2,cat3&t=tag1,tag2,tag3 Question is should I create custom taxonomies or custom queries to have generated related archive page? As an example “Test” post was categorized as “News” and “Business” and tagged as “Asia” and “China”. From that … Read more

How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero

Is there an easy way of obtaining every registered taxonomy and for each registered taxonomy, get all the terms for that taxonomy, and for each term, get the post count, without actually fetching all of the post data? I would assume it is most definitely possible. I would also assume it requires some massively long … Read more

SQL Statement generated by WP_Query not producing expected results

I am trying to alter WP_Query on the pre_get_posts action hook, for filtering the posts returned, depending on the built-in category and post_tag taxonomies. I would like that the only posts returned by the query have either both taxonomies not registered at all, or no term is set for both taxonomies for the post, or, … Read more

Custom SQL Query on Custom Post Type. Order by Taxonomy?

I’ve created a custom post type called ‘publications’ and a custom taxonomy called ‘topics’. I’m also using the standard taxonomy of ‘category’. My Custom Query makes sure that it fetches ALL ‘publications’ that are in the correct ‘category’ but I’d like it to also ORDER BY the additional ‘topics’ taxonomy. This custom query does fetch … Read more

WP_query taxonomy + get all posts with two terms from same taxonomy

This is a follow up question to Add_query_arg + two times the same argument? I want to get the post count from all posts tagged with 2 different tags from same taxonomy $args2 = array( ‘post_type’ => ‘custom’, ‘tax_query’ => array( ‘relation’ => ‘AND’ ) ); $args[‘tax_query’][0] = array( ‘taxonomy’ => ‘events’, ‘field’ => ‘slug’, … Read more