2

I'm running a WP_Query with a tax_query with two tax_query statements with an OR relationship.

$tax_query_terms = array(
                           array('taxonomy' => 'post_tag',
                                 'terms' => array(695),
                                  'field' => 'id'),
                           'relation' => 'OR',
                           array('taxonomy' => 'advisers',
                                 'terms' => array(301),
                                 'field' => 'id')
                        );

$related_articles = new WP_Query(array('tax_query' => $tax_query_terms,
                                             'post__not_in' => array(get_the_ID()), 
                                             'posts_per_page' => 3,
                                             'orderby' => 'date',
                                             'order' => 'DESC'));

When there are one or more posts for either term, it works correctly. When there are no posts matching either term, it returns all posts.

I would expect that if there are no posts matching either tax_query statement, then the query should return no posts. Am I wrong in this assumption?

(This seems to have been fixed for WordPress 3.5, but potentially has been re-introduced with the nested tax_queries for WordPress 4.1. - see https://core.trac.wordpress.org/ticket/20604 )

Am I misunderstanding this here, or should I file a bug on trac?

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.