php - How to Create a Select Filter for Parent and Child Categories -
i have wordpress category structure:
- state 1
- city name
- city name
- city name
- state 2
- city name
- city name
- city name
what need 2 selects works this: in first one, parent categories appear, in case states only, e. g. state 1 , state 2.
when 1 state selected next/second select should list children of selected parent, in above example city names.
example: when select new york (state) second select show new york cities. then, press search , should go http://mywebsite.com/state-selected/city/selected.
it works me now:
i used plugin: http://appelsiini.net/projects/chained. can see example, it's perfect.
then used get_categories( $args ) twice, each 1 inside 1 select element.
the first one, searching per parents , putting them options inside loop.
the second filtering children , putting them inside options well.
so, used chained jquery plugin!
Comments
Post a Comment