• Resolved tlw22

    (@tlw22)


    Hi,

    Is there anyway to display the categories of a post on single.php?

    e.g If I selected ‘cat1’ and ‘cat2’ as the categories of a post, at the bottom of the post page it displays ‘cat1’ and ‘cat2’ which then links to the corresponding categories.

    This code displays the first category, just wondering how to display all of them rather than 1:

    <?php
    						$category = get_the_category();
    						if ($category) {
    						  echo '<a href="' . get_category_link( $category[0]->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ';
    						}
    						?>

    Thanks to anyone who can help!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List Categories Of Posts’ is closed to new replies.