• Dario Ferrer

    (@metacortex)


    Hi,

    I’ve this code to show categories in dropdown way:

    <form action="<?php bloginfo('url'); ?>" method="get">
    <?php
    $select = wp_dropdown_categories('show_option_none=Select an option&show_count=1&child_of=5&echo=0');
    $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
    echo $select;
    ?>
    <noscript><input type="submit" value="Ver" /></noscript>
    </form>

    It works fine except a single detail: It don’t reset to ‘show_option_none’ once the category is clicked.

    For example, I have this structure:

    – Select an option
    — Countries
    — Towns
    — Streets

    When I click “Towns”, the form remains in “Towns”. I can refresh the page, clean chache & cookies and the %&#@$! list remains in “Towns”, when it must to be reset to “Select an option”. Which would be a solution for this?

Viewing 1 replies (of 1 total)
  • That’s a nice dropdown you have there.

    I’m doing something similar with dual dropdowns with both parent and child pages. I actually want the first page to stay at the selected parent page so that readers can see that they are select child pages in the second dropdown of that parent page displayed in the first dropdown.

    I’m gonna experiment with your code. ??

    Here’s my simple code that resets to the first item.

    `

    • <form action=”<?php bloginfo(‘url’); ?>” method=”get”>
      <?php wp_dropdown_pages(‘show_option_none=Select a Topic&depth=1&sort_order=ASC&exclude=2,3,4’); ?>
      <input type=”submit” class=”button” value=”Go!” />
      </form>
Viewing 1 replies (of 1 total)
  • The topic ‘Dropdown category don’t reset to first option’ is closed to new replies.