1

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

eg. cars, boats, aircraft, bicycles.

0

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 . ",";
}
|improve this answer|||||
  • 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 Jul 26 '13 at 8:15
  • @Steve deleted that , was planning a different way :) – Tolea Bivol Jul 26 '13 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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