Getting query_post(array(‘category__and’ => to work with variables not values?
-
Hello Guys
I’ve a new issue, tried for awfully long last night to get this to work, but with no success I need further guidance.
Basically the wordpress ‘query_posts’ codex page says use the following to display ONLY posts that belong to ALL of the defined categories.
query_posts(array(‘category__and’ => array(2,6)));
As we know this will display posts that ARE ONLY in both categories 2 and 6.
… Fair enough, very simple.However, in my situation the categories are defined from a form with option values (containing cat_ID) and selected by a user, then the values put into an array called $filter. The array is made with multiple if statements to verify wether or not an option has been selected.
Therefore I assumed the following would work:
query_posts(array(‘category__and’ => $filter));
.. But, it doesn’t. Any thoughts?
- The topic ‘Getting query_post(array(‘category__and’ => to work with variables not values?’ is closed to new replies.