0

i tried this code, it is not giving me any 404 page instead it is giving me the same page back, now i think the submit buttons needs to be configured

function the_taxonomy_dropdown($taxonomy) {
  $id = "{$taxonomy}-dropdown";
  $terms = get_terms($taxonomy);
  echo "<select name=\"{$id}\" id=\"{$id}\">";
  foreach($terms as $term) {
    echo '<option value="';
    echo get_term_link(intval($term->term_id),$taxonomy);
    echo '">' . "{$term->name}</option>";
  }
  echo "</select>";
}
add_action('init','jquery_init');
function jquery_init() {
  wp_enqueue_script('jquery');
}

this code was provided to me by one of the person from this website, i just modified it, this works but its just showing me the home page again

1 Answer 1

1

Just a standard HTML form will do!

<form action="<?php echo home_url('/'); ?>" method="get">

    <p><?php wp_dropdown_categories('taxonomy=taxonomy-1&name=taxonomy-1'); ?></p>
    <p><?php wp_dropdown_categories('taxonomy=taxonomy-2&name=taxonomy-2'); ?></p>
    <p><input type="submit" value="Search!" /></p>

</form>

Just replace taxonomy-1 and taxonomy-2 with the names of your taxonomies.

Important

If you registered your taxonomy with a custom query_var, you'll need to match it in the name argument of wp_dropdown_categories().

Also, querying multiple taxonomies is not supported as of 3.02 - you'll need the 3.1 beta, a plugin or additional filters.

7
  • i tried this but it is giving me 404 error for every search Dec 10, 2010 at 13:36
  • 1
    Did you install the plugin or additional filters as indicated? As has been said, multiple taxonomy queries are not supported "as is"..
    – t31os
    Dec 10, 2010 at 14:57
  • i am using GDCPT plugin for custom taxonomies, just that i am using for for custom taxonomies Dec 10, 2010 at 17:18
  • Could you post a link to the plugin? Dec 10, 2010 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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