Title: get_categories function
Last modified: August 18, 2016

---

# get_categories function

 *  [jkeyes](https://wordpress.org/support/users/jkeyes/)
 * (@jkeyes)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/get_categories-function/)
 * I have an archive dropdown working as follows:
 * `<select onchange="if (this.selectedIndex != 0) { window.location = this[this.
   selectedIndex].value; }">
    <option>Choose Month...</option> <?php get_archives('
   monthly','','option'); ?> </select>
 * I think a category dropdown that works in a similar fashion would be great e.
   g. `get_categories('format', 'name', 'before', 'after'); ?>`
 * `<select onchange="if (this.selectedIndex != 0) { window.location = this[this.
   selectedIndex].value; }">
    <option>Choose Category...</option> <?php get_categories('
   option', 'name'); ?> </select>
 * Of course this is not possible at the moment using the `dropdown_cats` function
   as it creates the `<select>`, therefore preventing me from adding the `onchange`
   attribute. It also sets the value attribute of each option to it’s index rather
   than the category URL which is required for changing the `window.location`.
 * Has this type of functionality been considered before?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/get_categories-function/#post-278712)
 * [Template_Tags/dropdown_cats](http://codex.wordpress.org/Template_Tags/dropdown_cats)
 *  Thread Starter [jkeyes](https://wordpress.org/support/users/jkeyes/)
 * (@jkeyes)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/get_categories-function/#post-278716)
 * Moshu, I edited my original post before you replied I think. If you re-read you’ll
   see my comments on the `dropdown_cats` function. I know I can do this myself 
   with code changes but I think this would be a useful addition to the codebase.
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/get_categories-function/#post-278717)
 * I see. You can always suggest changes in the hackers list, there is more chance
   the developers will see it 🙂
 *  [Chris Burgess](https://wordpress.org/support/users/xurizaemon/)
 * (@xurizaemon)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/get_categories-function/#post-279133)
 * There’s no need to modify core code here. With unobtrusive JavaScript you can
   make this form do what you want and not have to code JS into your HTML to boot.
 * It’s a little more code than just “onchange=’location.href=xxx'”, but it’s a 
   lot cleaner in the end.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘get_categories function’ is closed to new replies.

## Tags

 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 4 replies
 * 3 participants
 * Last reply from: [Chris Burgess](https://wordpress.org/support/users/xurizaemon/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/get_categories-function/#post-279133)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
