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 have two categories which I dont want to show to my site's admin, I want them to be added automatically everytime a new post is creatd or updated. I have the code for it. But now i also want to hide those two categories.

This is not for front-end. This is for wodpress dashboard. I dont want that admin will see these two categries at all. But if we hide those still I will be to assign two categories into posts.

Any clues???

share|improve this question
add comment

4 Answers 4

You need to create a custom taxonomy for your needs. You can hide it and it won't be visible. Read more about custom taxonomies:

  1. Custom Taxonomies
  2. register_taxonomy function
  3. Taking WordPress Custom Taxonomies to the Next Level
share|improve this answer
    
I found a plugin just now: wordpress.org/extend/plugins/restrict-categories which allow me to control which category will be displayed to which user and their roles. The good thing about this plugin is you can restrict categories not to show in admin mode where most of the other plugins will show everything in admin but has restriction to other users and their roles. I wanted something where i can hide two categories not to show in admin role and ofcourse all other roles. so complete hidden. this plugin does it. –  user17111 Jun 15 '12 at 4:59
add comment

Got an answer in the first version of this answer:

/*
 * Hide Specified Categories (by ID) from Editors
 */

add_action( 'admin_init', 'wpse_55202_do_terms_exclusion' );

function wpse_55202_do_terms_exclusion() {
    if( current_user_can('editor') )
        add_filter( 'list_terms_exclusions', 'wpse_55202_list_terms_exclusions', 10, 2 );
}

function wpse_55202_list_terms_exclusions($exclusions,$args) {
    return $exclusions . " AND ( t.term_id <> 1 )  AND ( t.term_id <> 17 )"; 
}
share|improve this answer
    
I dont understand following line: AND ( t.term_id <> 1 ) AND ( t.term_id <> 17 )" whats <> ?? –  user17111 Jun 15 '12 at 5:08
    
i love to use this code, but it seems its not working. i want to hide two categories from admin, not the editor. –  user17111 Jun 15 '12 at 5:12
    
Yes your code is working, sorry for my last message. i did chnage to administrator from editor, thats it. good one. thanks, now i dont need to use plugin. if( current_user_can('administrator') ) –  user17111 Jun 15 '12 at 5:15
add comment

I found a plugin just now: http://wordpress.org/extend/plugins/restrict-categories/ which allow me to control which category will be displayed to which user and their roles. The good thing about this plugin is you can restrict categories not to show in admin mode where most of the other plugins will show everything in admin but has restriction to other users and their roles. I wanted something where i can hide two categories not to show in admin. so complete hidden from any users including admin.

This plugin does it.

Though categories can be hidden you can assign a post to that category automatically, so everytime a new post is published it assigns automatically to those hidden categories.

Nice one.

share|improve this answer
add comment

Ok find the solution. thanks to @brasofilo.

the code is as follows:

add_action( 'admin_init', 'wpse_55202_do_terms_exclusion' );

function wpse_55202_do_terms_exclusion() { if( current_user_can('administrator') ) add_filter( 'list_terms_exclusions', 'wpse_55202_list_terms_exclusions', 10, 2 ); }

function wpse_55202_list_terms_exclusions($exclusions,$args) { return $exclusions . " AND ( t.term_id <> 69 ) AND ( t.term_id <> 70 )"; }

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.