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 ) { ?> 
<div>Length: <?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' ) );


Thanks for any clarity you can provide!

1 Answer 1


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.

  • That almost does what I want...for some reason, the utility text This entry was posted in %1$s and tagged %2$s. makes the Uncategorized "category" still get "attached" to the post, even though no categories are actually checked off. Since it's actually the utility text making the "category" appear, where do I edit the %1$s so that the utility text works ONLY when there is a real category (not Uncategorized, which wasn't even checked)!
    – Azurite
    Commented Mar 24, 2014 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.