• Resolved lanztuss12

    (@lanztuss12)


    Hi guys, my taxonomy in my custom post type were set to check mark and i want to change it to radio buttons because i only choose one for every taxonomy. how can i edit the settings?

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So, quick answer is that we don’t have a specific field for this type of thing. However, register_taxonomy DOES have a spot named 'meta_box_cb' that you can provide a function callback to be used to render the metabox in question. That makes you responsible for outputting everything.

    meta_box_cb
        (callback) (optional) Provide a callback function name for the meta box display. (Available since 3.8)
    
            Default: null 
    
    Note: Defaults to the categories meta box (post_categories_meta_box() in meta-boxes.php) for hierarchical taxonomies and the tags meta box (post_tags_meta_box()) for non-hierarchical taxonomies. No meta box is shown if set to false. 
    

    From https://codex.www.ads-software.com/Function_Reference/register_taxonomy

    So, how do you provide a value for a field that we don’t have a spot for. That’s actually pretty easy, especially if you’re familiar with filters and hooks. Please see the highlighted code at https://github.com/WebDevStudios/custom-post-type-ui/blob/release/custom-post-type-ui.php#L580-L592

    With this, you have one last chance to intercept all of the arguments that will be passed into register_taxonomy, and change, remove, add, etc, before returning. You can do it for all, you can use the extra parameters to do so conditionally. Really up to you. Just be sure to pass back the array to the CPTUI code so it can complete the registration. This will allow you to add the meta_box_cb index and a value for it to call instead.

    Should be all you need, but if you’re confused about anything, let me know and I will answer the best I can.

Viewing 1 replies (of 1 total)
  • The topic ‘How to make a taxonomy to radio button’ is closed to new replies.