bitbadger.solutions-blog-theme/source/_posts/2007/category-drop-down-in-wordpress.md
Daniel J. Summers 67dcb2f77c Initial import
brought over all the files from the Jekyll version, fixed categories,
reformatted for different markdown processor
2017-09-02 11:49:59 -05:00

1.5 KiB

layout title author date categories tags summary
post Category Drop-Down in WordPress Daniel 2007-05-24 09:00:15
Programming
JavaScript
Programming
PHP
WordPress
category
dropdown
wordpress
A category dropdown (select list) in WordPress

WordPress provides a template tag, wp_dropdown_categories, that inserts a drop-down list (the HTML <select> element) of categories, where the value of each item is the ID from the database. This works fine if you are not using rewrite rules (AKA "pretty links") - you can construct a URL using the value (?cat=[number]). However, if you use any sort of rewrite rules, this does not work. I recently converted my [personal site][], which uses the Pool theme, to utilize a JavaScript array to assist with displaying category pages.

Here's the code...

Edit: Code has been moved to this post.

This works for both "pretty" and standard links, as it uses the template tag get_category_link to specify the link.