WordPress.org

Ready to get started?Download WordPress

Forums

How to display only one Category name that a post is filed in? (1 post)

  1. rpesq
    Member
    Posted 6 years ago #

    Hi,

    Say I have a post filed in two categories, such as "Foo" and "Bar".

    What php code could I use to display only ONE of those categories?

    I know that (for example):
    <p class="postmetacomment"><?php the_category(', ') ?></p>

    ...will write ALL categories that the post was filed in, the example above would write "Foo, Bar".

    But how can I write just ONE of those category names? Say I just wanted to write either "Foo" or "Bar"?

    Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic