How can I hide the category term for posts with none set?

I'm trying to hide the word "Category:" from the metadata on the Twenty-Eleven theme's footer, when I don't have one set for a given post (sometimes I will manually remove the "Uncategorized" category, and sometimes I will be using Custom Post Types with Categories I have yet to create).

I know how I can do it with my custom post types' versions of "categories" and "tags:"

?php if (get_the_term_list( $post-ID, 'length' ) != null ) { ? 
divLength: ?php echo get_the_term_list( $post-ID, 'length', '', ', ', '' ); ?/div
        ?php } ?    

From my understanding, the above conditional says, "If you get the term list and it's got the taxonomy "length," and it's NOT empty, then go ahead and show the list for that term."

But for the existing Categories and Tags, how would I do it? I thought about using has_terms like so:

if( has_term( 'category' ) != null ) {
//do something
}

But I don't know what the 'something' is! I don't want it to display the categories if there are none (that what it's doing anyway), so should I be adjusting what's already there:

$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );

somehow?

Thanks for any clarity you can provide!

Topic conditional-tags post-meta categories Wordpress

Category Web


You could use:

<?php $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) ); if(has_category()) { echo $categories_list; } ?>

Here's the has_category function via the Codex.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.