Last active
June 18, 2020 19:36
-
-
Save johnlewisdesign/b6953a422a554738623287fa59a2b46a to your computer and use it in GitHub Desktop.
Hides categories from everywhere, even admin screens [WordPress/WooCommerce]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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