Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to customize the Categories meta-box when adding a post.

screenshot

I have added a custom post and I need the administrator to post a new post without the ability to use the top level categories and also, he can just choose only one category, no more than one category!

share|improve this question
    
function convert_root_cats_to_radio(){global $post_type; ?> <script type="text/javascript"> jQuery("#activitycategorychecklist>li>label input").each(function(){ this.disabled = "disabled"; }); jQuery("#activitycategorychecklist>li>ul>li>label input").each(function(){ this.type = 'radio'; }); jQuery("#activitycategory-tabs li:odd").hide(); </script> <?php} add_action( 'admin_footer-post.php', 'convert_root_cats_to_radio' ); add_action( 'admin_footer-post-new.php', 'convert_root_cats_to_radio' ); –  liying Jan 3 '13 at 9:50
    
I have solved as the code above ,thanx! –  liying Jan 3 '13 at 9:50
2  
Please add this as answer then. You can mark it as solved in two days. Help us helping you and later users with keeping the site clean. –  kaiser Jan 3 '13 at 12:42
    
How to mark it as solved? –  liying Jan 6 '13 at 6:19
    
Add it as answer, check back two days later, tick the check mark below the voting arrows. Thanks. –  kaiser Jan 6 '13 at 6:56
show 1 more comment

2 Answers

Freed from comment; the asker really did not want to write an answer. :/

function convert_root_cats_to_radio()
{
    global $post_type; 
    ?> 
<script type="text/javascript"> 
jQuery("#activitycategorychecklist>li>label input").each(function(){ 
    this.disabled = "disabled"; 
}); 
jQuery("#activitycategorychecklist>li>ul>li>label input").each(function(){ 
    this.type = 'radio'; 
}); 
jQuery("#activitycategory-tabs li:odd").hide(); 
</script> <?php
} 
add_action( 'admin_footer-post.php',     'convert_root_cats_to_radio' ); 
add_action( 'admin_footer-post-new.php', 'convert_root_cats_to_radio' );
share|improve this answer
add comment

My Radio Buttons for Taxonomies plugin converts any taxonomy (including categories) to radio buttons so that only 1 term can ever be selected. Though I guess it doesn't handle restricting/disabling the top-level terms.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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