• missing xbfish.com image

Dropdown menu for WordPress Archives

missing xbfish.com image
Posted on

As your wordpress ages on, the archives list is getting longer and longer. This doesn’t look neat and tidy at all. Hence, just replace the following code:

Original:

1
2
3
<ul>
   <?php wp_get_archives('type=monthly'); ?>
</ul>

Replace with:

1
2
3
4
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'> 
   <option value=""><?php echo attribute_escape(__('Select Month')); ?></option> 
   <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> 
</select>

Disclaimer :: The original archive code should be written in most wordpress theme. Just replace it and you will get:

For more template tags and regarding archives, do refer to http://codex.wordpress.org/Template_Tags/wp_get_archives

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam protection by WP Captcha-Free