Permalink
Browse files

Avert PHP notices when get_categories returns null results.

  • Loading branch information...
Charles Johnson
Charles Johnson committed Jun 8, 2012
1 parent 86165f3 commit b6b775fac54efa28af023a7f8d41fc4f3716c470
Showing with 9 additions and 4 deletions.
  1. +9 −4 fwp-keyword-filters.php
View
@@ -89,10 +89,15 @@ function fields_category () {
if (is_null($this->cats)) :
$this->cats = array();
$post_cats = $this->post->entry->get_categories();
- foreach ($post_cats as $cat) :
- $this->cats[] = $cat->get_label();
- $this->cats[] = $cat->get_term();
- endforeach;
+
+ // If we have any categories, then loop through them to get both
+ // label and term.
+ if (is_array($post_cats)) :
+ foreach ($post_cats as $cat) :
+ $this->cats[] = $cat->get_label();
+ $this->cats[] = $cat->get_term();
+ endforeach;
+ endif;
endif;
return $this->cats;
}

0 comments on commit b6b775f

Please sign in to comment.