I've created a hierarchical custom taxonomy (genre) and want to use it for a custom post type (radio station). But I don't only want to assign some genres to a radio station. I also want to be able to select one major/main genre as "most important genre" for each radio station.

Is it possible to do add a (native) "select only one [custom taxonomy]" field to the custom post type meta box in the admin area? Or is there even a more simple way to define one of the selected genres as the major/main genre?

Thanks for your help!


3 Answers 3


If I understand your question correctly, then it's a matter of joining the code from two answers from the following Questions of this Stack:

This is the result, top-level categories are converted to radio buttons, so only one can be selected.
The caveat is that sub-categories from other top-level categories can be selected as well.
result from code

As I mention in my answer to the second Question, Scribu's plugin, Category Checklist Tree, is almost a necessity for this scenario.

I'll not repost the full code, it's just a matter of replacing this lines:

jQuery("#categorychecklist>li>label input").each(function(){

For this ones:

jQuery("#genrechecklist>li>label input").each(function(){
    this.type = 'radio';

Attention to the ID of the <ul>:
enter image description here

For knowing which category is the "main category", from all selected parents or children, I can only think of a Custom Field to hold this information.

This could be solved programmatically, creating a new Meta Box, displaying a dropdown list with all categories, and saving this as post meta (update_post_meta).

And with a plugin, this can be done with Advanced Custom Fields and the Taxonomy Field add-on. Which results in:
acf categories

  • Thanks for your reply, but this is not quite what I was looking for (almost, though). I want to be able to select as many genres as I want, but define one of them (no matter what level) as the main genre. In your example I'd want to be able to choose {Genre 1,Genre2,sub-genre 1,sub-genre 3}, for example. And sub-genre 2 as main genre (maybe in a second Genres box). Most important for me to know is which genre I chose as main genre, later. Commented Jul 15, 2012 at 19:34
  • @RenéSchubert Updated the Answer, is that what you mean? . . . If so, please edit your Question to include the clarification you gave in the previous Comment.
    – brasofilo
    Commented Aug 2, 2012 at 7:35

You could do a main genre as one taxonomy and sub-genres as another (maybe "styles" or something) one? Then you could (shameless self-promotion) use my Radio Buttons for Taxonomies plugin to limit the metabox for the main genre to radio buttons. At the moment, you can still get around the radio button limitation in the quick edit, but I am working on that. Though it is difficult since there aren't any hooks to work with.

Granted this approach might not work well if you need the permalinks to line up somehow like:


Though technically you might be able to accomplish that with some slick rewrite voodoo. But if you are adding unlimited sub-genres then I doubt that'd ever work well.

But I know you can do:


where sub-genre is a and main-genre is a . I did this with »WooCommerce« once and modified the query for the main-genre page based on the sub-genre value. It was definitely tricky though.

However, from your description of 1 main genre and unlimited sub-genres, it makes me think of Categories and Tags for posts.

I'm just rambling here, though I suspect by now you've solved it somehow.

  • 1
    Could you please write in upper-/lowercase letters, format links properly or - in general - start using the powers of the WYSIWYG editor? I'll remove the down vote immediately. Not that I don't enjoy your answers, but it's extremely hard to read and as you already invested lots of time into writing the answer (or in all of your answers), why not make it easy to read? Thanks.
    – kaiser
    Commented Sep 8, 2012 at 0:29
  • 1
    I'm not sure how to format fake links (more permalink structure examples than URLs). And well, I don't have an excuse for capitalization except that it is a long-standing bad habit born of the natural arrogance of a native English speaker. I'll see what I can do... Commented Sep 8, 2012 at 1:20
  • Thanks. You can wrap [part of sentence](http://example.com) to let it become part of sentence. Or simply use the "link"-button in the editor.
    – kaiser
    Commented Sep 8, 2012 at 2:06
  • Even though I don't actually want them to link anywhere? As site.com is a fake construct. Commented Sep 8, 2012 at 2:20
  • 1
    Well thanks for the education. These aren't readily available in the WYSIWYG editor, so I never would've discovered that markdown without your help. Commented Sep 8, 2012 at 13:52
function convert_root_cats_to_radio() {
    global $post_type;
    if ('activity' == $post_type) {
    <script type="text/javascript">
        jQuery("#activitycategorychecklist>li>label input").each(function() {
            this.type = 'radio';
            var str=jQuery(this).parent().html().toLowerCase();
            if(str.indexOf("ageing") >= 0 || str.indexOf("everyone") >= 0 || str.indexOf("youth") >= 0) {
                this.disabled = "disabled";
        jQuery("#activitycategorychecklist>li>ul>li>label input").each(function(){this.type = 'radio';});
        jQuery('#activitycategory-tabs .hide-if-no-js').remove();

add_action('admin_footer-post.php', 'convert_root_cats_to_radio');
add_action('admin_footer-post-new.php', 'convert_root_cats_to_radio');

Your Answer

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

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