Display a custom taxonomy as a dropdown on the edit posts page

When you create a custom taxonomy, seemingly the only options are to display it as a tag (non-hierarchical) or category (hierarchical). Is there a way to display them as a dropdown menu?

I realise that this an be done using add_meta_box() and actually manually adding it, but I’m looking for a builtin way (if one exists), to save lots of code! Thanks.

5 Answers
5

Unfortunately there is no way of doing this with wp_register_taxonomy(). When you register a taxonomy, the default metabox is either checkboxes (hierarchical) or as a cloud (non-hierarchical).

The only way round it is to de-register the existing metabox and add a new-one in its place. By carefully mimicking the ‘default’ metabox – you won’t have to process the data yourself, but let WordPress automatically handle adding / removing terms.

The details of how to do this are given in this answer. You may also find this GitHub repository helpful (which now includes the ability of creating terms on the fly in the new metabox). The linked resources refer to creating a metabox with radio boxes, but it could be easily adapted for drop-down menus.

Leave a Comment