WordPress.org

Forums

How to show only one category for a post, need help... (2 posts)

  1. Spencer Hill
    Member
    Posted 3 years ago #

    I'm trying to display only the first category for a post but the_category() displays all of them and there don't seem to be any arguments to accomplish this. Can someone lend a hand? Thank you!

  2. NateJacobs
    Member
    Posted 3 years ago #

    Take a look at get_the_category

    <?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?>

    http://codex.wordpress.org/Function_Reference/get_the_category

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.