28

How to make each post/page have one and only one category. Categories could have radio box instead of checkbox next to each.

3 Answers 3

23

Actually, I wrote a plugin for exactly that.

http://wordpress.org/extend/plugins/radio-buttons-for-taxonomies/

In the plugin settings you define which taxonomies you'd like to apply this restriction to.

11

My prefered solution would be to use Advanced Custom Field with the Taxonomy field.

This way you can add a simple html select field for category, and in the same time hide the default wordpress categories widget.

https://www.advancedcustomfields.com/resources/taxonomy/

5
  • 1
    I'll definitely second this. The ACF plugin is great in the first place, and this solution is dead simple. Word of notice, I believe the Taxonomy Field Add-On is ACF 3 only, whereas ACF is now 4 and has Taxonomy fields built-in. Just remove your custom Taxonomies via the Screen Options tab. Jan 6, 2014 at 18:58
  • You're totally right, it's all built-in now :) Jan 6, 2014 at 22:20
  • 1
    Please correct me if i'm wrong but this method creates another field (posts meta) for storing the term links rather than using the default wordpress method (terms table). This means the standard wordpress features like the automatic admin column and taxonomy term counts don't work properly.
    – Phil_1984_
    Jun 16, 2015 at 14:06
  • That link is broken. Is there an updated link? Oct 28, 2015 at 5:58
  • ACF is great, but keep in mind that themes always accommodate the default post_meta of category. It's more flexible, but if you're just looking to restrict number categories to one per post type instance, it's not the fastest solution.
    – Archonic
    Dec 22, 2015 at 6:50
-3

From within the WordPress Admin, I haven't seen anyone modify category selection to force only 1 category. However, a good solution for you might be to use Gravity Forms. Using Gravity forms you can create a "front end posting solution" and in doing this you can set the category selection to use Radio Buttons instead of checkboxes. Alternatively you could also use a dropdown menu, again only allows 1 selection.

Another alternative is to modify the wp-admin area (which you will need to to in order to keep the WYSIWYG portion of the content editor as I don't think the front end solution provides this. I would suggest you remove the standard category meta box, very easily using code from this page: http://codex.wordpress.org/Function_Reference/remove_meta_box

And then create your own categories metabox using a dropdown value, which you can easily create from this page: http://codex.wordpress.org/Template_Tags/wp_dropdown_categories

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.