• Resolved jessica

    (@kerflop)


    I’ve been poking around for some time, and maybe these are out of style, but it is what my client wants.

    Is it still possible to create drop down menus for archives and categories in sidebar widgets? I’ve tried this code without luck, I just get an empty drop down box:

    <select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
      <option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
      <?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
    </select>

    I haven’t tried much with the categories drop down yet.

Viewing 1 replies (of 1 total)
  • Thread Starter jessica

    (@kerflop)

    I got this sorted, here’s the code I used:

    Browse by month:
    <div id="archive"><select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
      <option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
      <?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
    </select></div>
    <br />
    
    Browse by category:
    <div id="cats"><?php wp_dropdown_categories('show_option_none=Select category'); ?>
    
    <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>
Viewing 1 replies (of 1 total)
  • The topic ‘Drop down menus for archives and categories’ is closed to new replies.