Custom Taxonomy Control for the Theme Customizer

Otto had a series of articles highlighting how to use the theme customizer in your WordPress themes instead of creating an options panel.

One of his articles covered making your own custom control and it inspired me to make a custom control for showing a certain taxonomy dropdown on the theme customizer. At first, I had just wanted this for the purpose of choosing from a dropdown of categories to use as featured posts in my theme. Then I thought it could really just as well be used for any taxonomy object. Behind the scenes, this control is using the wp_dropdown_categories function, which allows you to build a dropdown of categories (or any other registered taxonomy).

The code for the control really wasn’t bad. After actually implementing this and trying to use it, I found that my changes were not being saved. There is a data-customize-setting-link attribute that must be appended to your element. Below is the code from my functions.php file and the class being called by functions.php: