'category__and' with multiple input
-
Hi,
I am wondering if I am able to get multiple input into ‘category__and’ (or ‘category’) argument separated by OR (or AND in ‘category’ case).I have something like this:
$args = array( 'posts_per_page' => '10', 'numberposts' => '', 'offset' => 0, 'category__and' => $category_array, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => false ); $myposts2 = new WP_Query( $args );
And it works great. But yesterady, the task changed and user now can choose more options in one filter category. So I need change query to something like this:
$args = array( 'posts_per_page' => '10', 'numberposts' => '', 'offset' => 0, 'category__and' => <strong>$category_array_1 OR $category_array_2 OR $category_array_3</strong>, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => false ); $myposts2 = new WP_Query( $args );
I can make those combination earlier in the code, but, I cant get this OR thing working and I can’t find any solution neither (maybe I am just blind). I am usualy capable to do my homewrok properly, but searchin for “OR” is kind of tricky…thanks for any help ??
EDIT: I can probably create a workaround with multiple queries, but I’d like to have it in one query.
- The topic ‘'category__and' with multiple input’ is closed to new replies.