Display Categories in a drop down Menu

For showing the categories in drop down menu just use the following code.


<li id="categories"><h2><?php _e('Posts by Category'); ?></h2>
 <?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>
</li>

For more information you can use the following code.

You may like following Articles!

  • http://wordpressapi.com Wordpress API

    Thanks.

  • http://bakingparchmentpaper.com Daitrice Morfin

    I’m really glad I have found this information. Today bloggers publish only about gossips and web and this is really annoying. A good web site with interesting content, that is what I need. Thank you for keeping this website, I will be visiting it. Do you do newsletters? Cant find it.

  • http://uautoclub.com Jeff Olive

    I was just having a conversation over this I am glad I came across this it cleared some of the questions I had.

  • http://Crafts-Hobbies.info Haywood Rochin

    I would like to say “wow” what a inspiring post. This is really great. Keep doing what you’re doing!!

  • http://traffic2website.info Elizbeth Tommolino

    This post makes a lot of sense !

  • http://oluenxypvk3573.blogspot.com/ Michel Mayen

    I REALLY liked your post and blog! It took me a minute bit to find your site…but I bookmarked it. Would you mind if I posted a link back to your post?

  • http://oluenxypvk3573.blogspot.com/ Corinne Rhein

    Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.

  • http://the-business-cards.info Pete Widrick

    Intriguing post. I have been searching for some good resources for solar panels and discovered your blog. Planning to bookmark this one!