Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying out a couple of plugins to aid in searching of taxonomy terms. One is called "Query Multiple Taxonomies" and the other is called "Drop-down-custom-taxonomy".

What I'm wanting to keep the page I'm searching from when I begin the search. For example if the page I'm on is dogs (www.site.com/dogs) and I run a search on this page for a taxonomy called "breed", and find all dogs that are a "beagle", the url is changed to this:

www.site.com/?breed=beagle

How can I get the url to stay with /dogs in it?

www.site.com/dogs/?breed=beagle

Based on my limited knowledge, I'd say this is a job for url rewriting? I did try adding some code for a base url for Query Multiple Taxonomies but this did not work with my permalink structure of /%year%/%postname%/

share|improve this question

1 Answer 1

Just change the action attribute of your search form in your theme, for example;

<form action="<?php echo home_url( $GLOBALS['wp']->request ); ?>" method="get">

This will dynamically output the URL of the current request, so that when a user searches, the query string is simply appended to it, rather than pointing back at the root.

share|improve this answer
    
Thanks, nice tip. This fixes the default WP search box but it doesn't have any effect on the taxonomy dropdowns I am using. They still start searching from the homepage. I found that Query Multiple Taxonomies has a "base URL" filter that can be set but it doesn't work with my /%year%/%postname%/ permalinks. github.com/scribu/wp-query-multiple-taxonomies/wiki/… –  Andrew Jul 5 '11 at 23:23
    
The other plugin uses the following. Perhaps I can modify the window.location.href? <script type="text/javascript"> jQuery(document).ready(function($){ $("select#{$id}").change(function(){ window.location.href = $(this).val(); }); }); </script> –  Andrew Jul 5 '11 at 23:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.