Advertisement
fauzanjeg

Category Widget Filter || Exclude Category by Slug

Oct 17th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. /** Category Widget Filter || Exclude Category by Slug */
  2. function filter_category_widget( $cat_args, $instance ) {
  3.     $list_slug = array( 'apps', 'review', 'world', 'business', 'category-test-slug' ); /* Category Slug */
  4.  
  5.     foreach( $list_slug as $slug ) {
  6.         $cat_args['exclude'][] = get_category_by_slug( $slug )->term_id;
  7.     }
  8.  
  9.     return $cat_args;
  10. }
  11. add_filter( 'widget_categories_args', 'filter_category_widget', null, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement