I need to display some HTML only if the post being displayed has a category – not a specific category, just any category at all.

I tried if (!is_empty(get_the_category($post->ID))), but for some reason this isn’t working. Has anone else had the same issue?

1 Answer
1

Use has_category instead.

if (has_category('',$post->ID)) ...

If you want to use it in The Loop, you don’t need to specify the ID.

if (has_category()) ...

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *