Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wp_hide_category( $query ) {
- if( ! is_admin() && $query->is_main_query() ) {
- $wp_hide_category_hide_place = get_option( 'wp_hide_category_hide_place' );
- $category_hide = explode( ',', get_option('wp_hide_category_id') );
- if( !empty( $wp_hide_category_hide_place ) ) {
- foreach( $wp_hide_category_hide_place as $template_name ){
- $call_name = 'is_' . $template_name;
- if( $query->$call_name() ){
- if( !empty( $category_hide ) ) {
- foreach( $category_hide as $cat_id ) {
- $query->set( 'cat', '-' . $cat_id );
- }
- }
- }
- }
- }
- }
- }
- add_action('pre_get_posts' , 'wp_hide_category');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement