Search code examples
phpwordpresswp-list-categories

Filter out posts using custom Post Query


I am trying to use the categories to make some sort of taxonomy picker. I have a site, which I’m running locally for event planning; I have 6 categories with sub categories within them. For example if someone is looking for a band, they go into the band category and then it displays all the posts within that category.

I want to use the sub categories to narrow the search down so people searching for bands but want classical will find just those posts. But I want to do it by asking them a question, like “What sort of band are you looking for?” then they select from a drop down of sub categories for the bands. They will do this for each category, make a selection or none so that it gives them a list of only what they are looking for.

Maybe after each selection, it adds that category into an array which is then used for a wp post query?


Solution

  • If you are going to post it then you can just build your query based on the posted variables

    e.g.

    myql_query("select * from table where catogory = '{$_POST['Cat']}' and subcat = '{$_POST['subcat']}');
    

    However if you want it down when they pick it with out refreshing the page then you need to look at AJAX