I have posts with the following categories:
A category that is a year(2017,2018...2022), a category that is type:(worldwide,Europe, local)
I am trying to give users in the frontend advanced search ability they have two multislectmultiselect dropdown, they can pick a year or several. and a type. (both of these are technically categories)
For example "select post from cat 2017select post from cat 2017
or cat 2018 cat 2018
AND that are (cat=Europecat=Europe
or cat=localcat=local
)`
I am having trouble mixing the "and" and "or" efficiently... in get_postsget_posts
.
For instance I can do something like:
$posts = get_posts(array( 'category__and' => array(1,10) )); // assuming 10=category Europe, 1 =category 2016,
$posts = get_posts(array( 'category__and' => array(1,10) )); // assuming 10=category Europe, 1 =category 2016,
So I just do a loop like
Foreach $year in list of years:
foreach $type in list of types
get_posts(array( 'category__and' => array($year,$type) ));
Is there a more efficient way to combine my conditions?
Thanks