Hide Categories from WordPress Dashboard by ID and Custom Post Type
-
I recently went searching for a solution to hide specific categories by ID on a WordPress dashboard for individual custom post types. I stumbled upon the following code and was able to get half way there by hiding categories by logged in user.
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 <> 43 ) AND ( t.term_id <> 42 )"; }
I now want to alter this code to hide ID specified categories taking the custom post type into account. I know i can pass an argument with the current_user_can but I’m not sure how to phrase it. Unfortunately a custom taxonomy which I have implemented in other aspects of the site is not going to work in this instance.
I thought all I had to do was swap the if statement conditional with a get_post_type but it did not work. Any ideas?
'andytoday' == get_post_type()
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hide Categories from WordPress Dashboard by ID and Custom Post Type’ is closed to new replies.