Displaying a specific post in category/archive template? (3 posts)

  1. hobbahobba
    Posted 8 years ago #

    I have a category called "cars" (it's ID # is 9). I want to have a category template page that shows BOTH a specific post (that sticks out on top of content as a "welcome post") then it proceed with looped posts with "cars" category on them.

    So it looks something like this:

    Welcome Post (sticks out in front of page)
    cars post #9
    cars post #8
    cars post #1

    I can mod the php file so that the welcome post will be static. But since I'm doing a page for someone who is not php savvy and likes to change content in welcome post, I have to generate the welcome post off the admin.

    So I used

    // retrieve one post with an ID of 5

    And it pulls up the welcoming post but the following cars posts don't show up. It seems like it kills the loop.

    Please help

  2. Eric Amundson
    Volunteer Moderator
    Posted 8 years ago #

    You could to do something like:

    <?php query_posts('pagename=carswelcome'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_title('<h4>', '</h4>'); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    I'd place it right above the loop in its own <div> maybe.

  3. hobbahobba
    Posted 8 years ago #

    Thanks, will try it.

Topic Closed

This topic has been closed to new replies.

About this Topic