I've been searching the web and rattling my brain for weeks but to no avail.
I have a product database on WordPress (v3.4) and I am trying to make it searchable using URL queries.
Ideally this is the scenario I want:
- domain/products - to show all of the products
- domain/products?tax1=term1 - to filter the products by a taxonomy
- domain/products?tax1=term1&tax2=term2 - to filter my multiple
taxonomies.
The post_type is called 'product' and I currently have a page called products with a page-template assigned to it. However, whenever I try to use the WordPress URL queries is redirects me to a similar URL'd news post (e.g. domain/2011/10/01/products-are-cool).
How do I go about creating these filters and having them display the results correctly?
UPDATE: I've come up with a solution that works perfectly for me.
if(isset($_GET)) $options = $_GET;
if (!empty($options)) {
$posts = new WP_Query( array(
'post_type' => 'product',
'orderby' => 'title',
'order' => 'asc',
'paged' => $paged,
'tax1' => $options['tax1'],
'tax2' => $options['tax2'],
));
And then use add_query_arg($termslug,$term->slug)
to append the taxonomies onto the URL.