Forums

Adding Category Title to First post only (2 posts)

  1. danvoyce
    Member
    Posted 1 year ago #

    I'm using the theme twentyten as my base template and have styled and tweaked to fit my websites design and needs.

    The home page displays 3 blogs (each as a category). I have used the following code to display the Category title above the posts, as it doesn't display by default.

    [please mark the code using the 'code' button]

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

    The problem with this is it displays above every individual post, and I only want it to display above the first post in each category.

    I guess i am needing a bit of code that says if first (latest) post of category, display category name.

    Help please wordpress gurus!

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    it might help to be able to see the full template code;
    please paste the code into a http://pastebin.com/ and post the link to it here.

Topic Closed

This topic has been closed to new replies.

About this Topic