diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 3c7d10e215..385567babe 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -238,7 +238,10 @@ function wp_list_categories($args = '') { $output .= __("No categories"); } else { global $wp_query; - $r['current_category'] = $wp_query->get_queried_object_id(); + + if ( is_category() ) + $r['current_category'] = $wp_query->get_queried_object_id(); + if ( $hierarchical ) $depth = 0; // Walk the full depth. else diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 5ae587cb7f..b9713af0d9 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -619,13 +619,14 @@ class Walker_Category extends Walker { $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); } - $_current_category = get_category( $current_category ); + if ( $current_category ) + $_current_category = get_category( $current_category ); if ( 'list' == $args['style'] ) { $output .= "\tcat_ID == $current_category) && is_category() ) + if ( $current_category && ($category->cat_ID == $current_category) ) $output .= ' class="current-cat"'; - elseif ( ($category->cat_ID == $_current_category->category_parent) && is_category() ) + elseif ( $_current_category && ($category->cat_ID == $_current_category->category_parent) ) $output .= ' class="current-cat-parent"'; $output .= ">$link\n"; } else {