TypeError thrown

count(): Argument #1 ($value) must be of type Countable|array, WP_Post given