From aedf76aa2f84c74b194b6abbe402b1eb65999cc3 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 1 Dec 2006 18:55:27 +0000 Subject: [PATCH] Avoid empty result category queries. Props andy. fixes #3416 git-svn-id: http://svn.automattic.com/wordpress/trunk@4580 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category-template.php | 5 ++++- wp-includes/classes.php | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 3c7d10e21..385567bab 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 5ae587cb7..b9713af0d 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 {