Home > Tech & Web > Radio Button Categories in WordPress

Radio Button Categories in WordPress

If you’re like me and have multiple authors adding content to your site, you may find that the standard checkbox system of selecting categories is far from perfect. It allows users to add a post to more than one category which could be a problem dependant on your theme. Google may also see this as duplicate content on your site which should be avoided.

Unfortunately, WordPress by default doesn’t allow you to change the checkboxes to radio buttons, but luckily for us we can use a simple str_replace function to change the check-boxes to radio buttons and thus forcing users to put their posts in only one category.

I’ve put in a conditional clause to ignore Administrators as the str_replace will actively change all checkboxes to radio buttons on the page which can cause a problem if you have multiple plugin options that you need to set individually for different posts.

This is by no means a perfect solution and has its obvious limitations but figure it would be helpful for others out there.

To use, simply drop the following code into your themes functions.php file and off you go. Simple.

// Select only one category on post page by Paul @ Live Free Die Travelling

 if(!current_user_can( 'activate_plugins' ) && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || 
 strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php'))) 
 		function one_category_only($content) {
 		$content = str_replace('type="checkbox" ', 'type="radio" ', $content);
 		return $content;

This has been tested with WordPress 3.5.1, I cannot guarantee it will work with earlier versions, but see no reason why it wont. If anyone has a more elegant solution please let me know in the comments section below.


Any questions or feedback can be directed to the comments section below and I'll get back to you as soon as I can.  :-D

Get New Posts via Email

Weekly updates sent to your inbox

Become an Author

Travel, write and earn money
Like this page? Show some love and share with friends...

About Paul

Becoming financially independent and travelling the world has been a dream of mine since I was young. In 2012 I decided to dedicate my life to travel. I will document my journey through this site.

Check Also

Adding Watermarks to Your Photos using IrfanView (awesome free program)

Adding watermarks to your photographs can not only help protect your photographs from being fraudulently …


  1. What if I want to set a starting category as selected and give the users the choice to change it or post in it?

  2. Hey Andrea,

    Thanks for your comment. The function you require is actually a built in function of WordPress (if I’m understanding you correctly?).

    In order to change WordPress default post category you will need to go to Settings => Writing and change the default post category in there. Be default it is set to ‘uncategorised’, I would recommend deleting that category after you make your changes if you don’t need it.

    I hope this is of some help?


  3. Hello

    What a smart idea! The only thing I miss there is that users are limited with 1 selectable category only but admins. I mean it could be role-based – ie. admin and editors may access check-buttons, all other user roles – radio buttons only. DO you think it is possible?

  4. Ok thank you!
    One more question: is it possible to make the hack working so that authors may pick up a defined amount of categories among all available so it would be possible to select, 1, 2 or 3 categories but no more?

  5. Hi there, great solution.

    I need a slightly different one though…in that I have two categories that are mutually exclusive, the rest can be checkboxes, any way to do it?

    So category A/B are radio buttons, then categories C/D/E/F/G are all checkboxes.



    • Hi Ian,

      I use the following code to *DISABLE* the parent checkboxes, you could have a play around with the jquery to convert them into radio buttons instead of disabling them. I don’t have time at the moment to test anything for you, maybe someone else here does… either way I hope it helps?

      add_action( ‘admin_footer-post.php’, ‘disable_top_categories_checkboxes’ );
      add_action( ‘admin_footer-post-new.php’, ‘disable_top_categories_checkboxes’ );

      function disable_top_categories_checkboxes() {
      global $post_type;

      if ( ‘post’ != $post_type )

  6. Ok thanks….just wondered if perhaps you could target specific category IDs, not sure quite how to do it though.

  7. Ok thanks….just wondered if perhaps you could target specific category IDs, not sure quite how to do it though.

  8. Hi Paul,

    Just to let you know… I released a plugin that will handle this for any taxonomy that you like.



  9. Hi, nice share, exactly looking for this. But, I am unable to select the code snippet 🙁 . So, not able to test those code in my blog. Please help me.

    • Hello,

      Thanks for highlighting this issue. It should be fixed now and you should now be able to highlight and test the code. Any problems, let me know, thanks, Paul.