diff --git a/course/lib.php b/course/lib.php
index f3c81f7b6ce..a00348f3269 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -2265,7 +2265,9 @@ function print_category_info($category, $depth=0, $showcourses = false) {
echo '
';
$html = '';
$cat = html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $fullname, $catlinkcss);
- $cat .= html_writer::tag('span', ' ('.count($courses).')', array('title'=>get_string('numberofcourses'), 'class'=>'numberofcourse'));
+ if (count($courses) > 0) {
+ $cat .= html_writer::tag('span', ' ('.count($courses).')', array('title'=>get_string('numberofcourses'), 'class'=>'numberofcourse'));
+ }
if ($depth > 0) {
for ($i=0; $i< $depth; $i++) {