Skip to content

Commit 19b10b4

Browse files
committed
Fix error when post has no categories
1 parent 680797c commit 19b10b4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PostTypes/Post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function withCategories()
9999
{
100100
$this->categories = \array_map(function (WP_Term $term) {
101101
return (new Category($term->term_id))->withAll();
102-
}, \get_the_terms($this->WP_Post, 'category'));
102+
}, \get_the_terms($this->WP_Post, 'category') ?: []);
103103

104104
return $this;
105105
}

0 commit comments

Comments
 (0)