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

eg. cars, boats, aircraft, bicycles.

1 Answer 1


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 . ",";
  • 1
    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
    Commented Jul 26, 2013 at 8:15
  • @Steve deleted that , was planning a different way :) Commented Jul 26, 2013 at 8:20

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.