WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Sidebar Category Drop Downs (2 posts)

  1. xaine05
    Member
    Posted 4 years ago #

    Hi Everyone,

    I'm wondering if I can have a bit of assistance with a sidebar drop down menu for categories. I have managed to get it working and only display the child categories as needed but because of Java Script I cannot have more than one instance and I would really like to have two instances of the drop down menu one for clothing brands and one for clothing styles. Below is my current code to allow the categories, if anyone can shed light on having multiple instances it would be appreciated. The site to reference is my work in progress http://www.golfclothingwear.co.uk

    <li id="quick-search">
                <div class="widget">
                    <h2>Shop by Brand</h2>
                    <?php wp_dropdown_categories('show_option_none=Select Brand&hierarchical=true&child_of=3'); ?>
                    <script type="text/javascript"><!--
                        var dropdown = document.getElementById("cat");
                        function onCatChange() {
                            if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
                                location.href = "<?php echo get_option('home');
                    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
                            }
                        }
                        dropdown.onchange = onCatChange;
                    --></script>
                </div>
            </li>
  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    Give them different names and it should work fine (update JS accordingly).
    http://codex.wordpress.org/Template_Tags/wp_dropdown_categories

    See the "name" parameter.

Topic Closed

This topic has been closed to new replies.

About this Topic