Is there a way to replace the default checkboxes by radio buttons in the custom post type taxonomy UI?
I have custom post type ‘questions’ with taxonomy ‘answer type’ (single selection [radio button], multiple selection [checkboxes] and pattern matching [dropdown boxes). I need to make sure the users can only pick one option from ‘answer type’. Is there a way to get this done?
Leave a Reply
You must be logged in to post a comment.
When you register a taxonomy WordPress automatically handles producing the appropriate metabox. First you need to ‘de-register’ this default metabox:
Where
my-tax-metabox-id
is the ID of your metabox. Then ‘re-register’ the metabox providing your own callback function which produces in the output:Then it is simply a matter of mimicking the ‘default’ hierarchal metabox markup but altering the checkboxes to radio buttons. The function that is responsible for producing the default mark-up can be found here: http://core.trac.wordpress.org/browser/tags/3.3/wp-admin/includes/meta-boxes.php#L307
I show in detail how to do this in this article I wrote. You may also find this corresponding repository helpful.