diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 113173e04..8804327d1 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -1047,19 +1047,21 @@ function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_ $all = apply_filters('list_cats', $all); echo "\t\n"; } - foreach ($categories as $category) { - $cat_name = apply_filters('list_cats', $category->cat_name); - echo "\t\n"; + if ($categories) { + foreach ($categories as $category) { + $cat_name = apply_filters('list_cats', $category->cat_name); + echo "\t\n"; + } } echo "\n"; } @@ -1087,6 +1089,15 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; $categories = $wpdb->get_results($query); + + if (!$categories) { + if ($list) { + $before = '
  • '; + $after = '
  • '; + } + echo $before . "No categories" . $after . "\n"; + return; + } ++$querycount; if (intval($optionall) == 1) { $all = apply_filters('list_cats', $all); @@ -1094,6 +1105,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde if ($list) echo "\n\t
  • $link
  • "; else echo "\t$link
    \n"; } + foreach ($categories as $category) { $cat_name = apply_filters('list_cats', $category->cat_name); $link = '';