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???

4 Answers
4

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 )"; 
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *