Skip to content

Instantly share code, notes, and snippets.

@johnlewisdesign
Last active June 18, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlewisdesign/b6953a422a554738623287fa59a2b46a to your computer and use it in GitHub Desktop.
Save johnlewisdesign/b6953a422a554738623287fa59a2b46a to your computer and use it in GitHub Desktop.
Hides categories from everywhere, even admin screens [WordPress/WooCommerce]
/*
* Hide Specified Categories (by ID) from administrators
*/
add_action( 'admin_init', 'jl_do_terms_exclusion' );
function jl_do_terms_exclusion() {
if( current_user_can('administrator') ) {
add_filter( 'list_terms_exclusions', 'jl_list_terms_exclusions', 10, 2 );
}
}
function jl_list_terms_exclusions($exclusions,$args) {
return $exclusions . " AND ( t.term_id <> 16 ) AND ( t.term_id <> 15 )";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment