Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function filter_widget_categories_args( $args ) {
- if ( is_category() ) {
- $current_category = get_queried_object();
- if ( $current_category && ! is_wp_error( $current_category ) ) {
- $args['child_of'] = 0 !== $current_category->category_parent ? $current_category->category_parent : $current_category->term_id;
- if ( empty( get_categories( $args ) ) ) {
- unset( $args['child_of'] );
- }
- }
- }
- return $args;
- }
- add_filter( 'widget_categories_args', 'filter_widget_categories_args' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement