How to combine tax_query and date_query in WordPress

I’m afraid that there is no way to do such advanced queries using WP_Query.

But, of course, you can still achieve that result, but you’ll need to write a little bit more code.

There are two solutions:

It’s hard to give you precise code, because there aren’t many details in your question, but maybe this will be enough 🙂

1. Use posts_where and posts_join filters

If you’re not afraid of writing your own SQL queries, then you can use posts_where and posts_join filters to add some more advanced SQL conditions to your WP_Query.

2. Use second WP_Query and then exclude these posts

If you don’t like raw SQL, then you can use second WP_Query. Use it to select all posts that you want to exclude. Then you can use their IDs and pass them as post__not_in param to your current WP_Query – this way you will exclude them.

Leave a Comment