Put a Drop Down Menu for Categories in the Sidebar
I was asked by a few readers on my Working at Home on the Internet Blog about the procedure for putting a Drop Down Menu in the Sidebar for the Categories. It seems I’m not the only one who has too many categories and not enough room to show them all.
It is a fairly simple bit of code to add a Drop Down Menu…
- Go to your Sidebar php
- Locate the code <?php get_categories (); ?> or <?php wp_list_cats (); ?>
- Replace that code with the following:
- <h2>Categories</h2>
<ul class=”sellLi”>
<form action=”<?php bloginfo(’url’); ?>” method=”get”>
<?php wp_dropdown_categories(’show_count=1&hierarchical=1&orderby=name’); ?><br />
<input type=”submit” name=”submit” value=”View” />
</form>
</ul> - Save your Sidebar php
- Done
If you are using Widgets, you may need to get a plugin by Otto that allows the use of php code within a Widget! Go to his post Fun with Widgets and look for the execphp.zip file.
Download it, unzip it, upload it to your server wp-plugins file and you will be able to use the above php code in the Widgets and you will have the same DropDown Menu you see in my Sidebar on the WAHI Blog.
Article Series - WordPress Tweaks
- Want Post Preview Back in WordPress?
- How to Insert Titles Instead of Previous/Next Links
- Put a Drop Down Menu for Categories in the Sidebar
- How To Put AdSense Ads After A Single Post per Page
- Step by Step Installation of WordPress Plugins