I’m coming up short with my googling here. (As ‘filter’ in wordpress always turns up more content related info).
Anyway, my situation is this: I have Categories
, Tags
, Authors
and Archive
dropdowns on my blog page (using the built in wordpress dropdown functionality (http://codex.wordpress.org/Function_Reference/wp_dropdown_categories, for example).
I want to be able to combine these filters; such that if you choose a category Hats
, and then when you have your list of results if you choose Blue
from the dropdown you would get anything that matched both Blue
and Hats
. (Or if you choose a month, you’d get the posts that matched Blue
and Hat
from your chosen month.)
I know there has to be a way to do this. But I’m coming up short even figuring out where to start. (I’m certain there was a plugin that did this that I wanted to look at, but I can’t even find that.)
So… If anyone has any ideas about how to start this that would be amazing. Or even just an example plugin I can look at to glean some info (I really want to code this myself so I understand what is going on).
To get you started: you can make a custom form (I never worked with wp_dropdown_categories). When the form is submitted, it gets the input variables and uses them in the query.
The form could be something like:
And then on the resultspage
A few notes. First, this is not tested. Second, check the codex on WP_Query how to use these (and other) arguments and what kind of input they need. For instance, you can use
'tag'
and input the tag slug, but you can also use'tag_id'
and use the tag ID as input. Then you would change the option value of the tags select field. Third: I don’t know what you would like to do with the archives. Would you like to display posts from a certain month? This can be achieved with a meta_query (you can find documentation in the WP codex).Is this a good start? Let me know if it worked out.