Title: Using WP Dropdown Categories
Last modified: August 19, 2016

---

# Using WP Dropdown Categories

 *  Resolved [mhuynh55](https://wordpress.org/support/users/mhuynh55/)
 * (@mhuynh55)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/using-wp-dropdown-categories/)
 * I am currently implementing an archive index by an author and was seeing if someone
   here could assist me as I do not know PHP in-depth.
 * The following php displays a list of categories as a drop-down menu:
 *     ```
       <?php wp_dropdown_categories('orderby=name&show_count=1&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>
       ```
   
 * I was hoping that rather than for the drop-down menu to show all the categories
   I have created through my WP Dashboard, I could only show specific categories
   only. For example, could I specify only the drop-down menu to show cat=16 or 
   9?

Viewing 1 replies (of 1 total)

 *  Thread Starter [mhuynh55](https://wordpress.org/support/users/mhuynh55/)
 * (@mhuynh55)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/using-wp-dropdown-categories/#post-969852)
 * If anyone else requires future reference, the solution was just to amend the 
   code and add _&exclude=10_ to:
 *     ```
       <?php wp_dropdown_categories('orderby=name&show_count=1<strong>&exclude=10</strong>&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>
       ```
   

Viewing 1 replies (of 1 total)

 The topic ‘Using WP Dropdown Categories’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [mhuynh55](https://wordpress.org/support/users/mhuynh55/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/using-wp-dropdown-categories/#post-969852)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
