WP_Query with OR conditions

Here is an issue, I have a site that has sort of complex search. I have set several arguments: s, meta_query, tax_query and post_type

Obviously these are all linked with AND relationships (except meta_query and tax_query that can be set with OR relationship, but I need to get posts that have entered phrase at either title or content or some of meta values, or some of taxonomies.

Read More

Any way of doing so?

Related posts

Leave a Reply

1 comment

  1. You should use relation parameter.

    UPDATE:

    Example from a page linked above:

    $args = array(
        'post_type' => 'post',
        'tax_query' => array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'movie_genre',
                'field'    => 'slug',
                'terms'    => array( 'action', 'comedy' ),
            ),
            array(
                'taxonomy' => 'actor',
                'field'    => 'term_id',
                'terms'    => array( 103, 115, 206 ),
                'operator' => 'NOT IN',
            ),
        ),
    );
    $query = new WP_Query( $args );