0

I am using the following wp_query to pull up a list of post, and I want to exclude a few categories of a custom taxonomy.

It works well, however Query Monitor is telling me that the query is slow.

I removed the 'tax_query' part of the query and it sped up.

Is there a faster way to exclude these categories?

Thanks!

My Query:

$args = array( 'post_type' => array( 'recipe' ), 'post_status' => array( 'publish' ), 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => 40, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'ingredients', 'field' => 'slug', 'operator' => 'NOT IN', 'terms' => array( 'onion', 'pepper', 'bean' ) ) ) ); 
2
  • Is there some concept that groups the taxonomies that you don't want to display? You'd be better off with a custom taxonomy and term that you apply to the posts that you do want to display. Commented May 9, 2022 at 6:36
  • @JacobPeattie Currently, no. I could add a "Exclude from Loop" checkbox to the taxonomy via term meta, but wouldn't that be slower? Commented May 9, 2022 at 6:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.