The MU forums have moved to WordPress.org

How to display only one or two Categories (5 posts)

  1. boonika
    Member
    Posted 15 years ago #

    This is the situation. When viewing post (let say it is published in 5 categories) on my homepage (index.php) I want viewer to see only one (or two) category in which post has been published. It should look something like this:

    My Post Title
    Category 1, Category 2,...

    Thanks,
    B

  2. dsader
    Member
    Posted 15 years ago #

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

    from

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

  3. boonika
    Member
    Posted 15 years ago #

    Thanks a lot Dsader... huh... dumb... I guess I could have search for it myself. Do You have any Chinese saying that could help me survive:)

    Cheers

  4. dsader
    Member
    Posted 15 years ago #

    How about from the Bhagavad Gita, instead?

    “As the blazing fire reduces wood to ashes, similarly, the fire of Self-knowledge reduces all Karma to ashes.”

  5. boonika
    Member
    Posted 15 years ago #

    Thanks:) I'll quote Chris from "Everybody hates Chris" (with a little change):

    "Dsader has some kind of power to make me feel as the smartest idiot in the world"

    I think that original goes something like; "My mother has some kind of power..."

    Cheers!

About this Topic