WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I display all of the categories that a post is in, in sentence format.

eg. cars, boats, aircraft, bicycles.

share|improve this question
up vote 0 down vote accepted

In the loop use <?php the_category(', '); ?> or outside the loop :

$post_categories = wp_get_post_categories( $post_id );

foreach($post_categories as $c){
    $cat = get_category( $c );
    echo $cat->name . ",";
share|improve this answer
is there a spelling mistake there - you're using cats on one hand and cat on the other. cats is not used anywhere else – Steve Jul 26 '13 at 8:15
@Steve deleted that , was planning a different way :) – Tolea Bivol Jul 26 '13 at 8:20
Perfect, thank you Tolea. – Steve Jul 26 '13 at 8:21
You're welcome Bro – Tolea Bivol Jul 26 '13 at 8:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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