Forums

[resolved] list 1 entry for announcements category (3 posts)

  1. rickmesser
    Member
    Posted 1 month ago #

    Generally new to WordPress & php but very excited about it!
    Good with XHTML/CSS.
    Trying to make an announcement section on the homepage more dynamic. I created a category called "announcements" and I want a small section on the homepage to be updated with the 1 most recent post under "announcements" category.

    Currently I just have:

    <?php include(TEMPLATEPATH.'/announcement.txt'); ?>

    That's work for now but I want to give my client the control to update it. I don't know how to get it to do what I want it to. I have searched the forums/codex but I'm not looking for the right keywords I think.

    Here's the site (under development)
    http://www.achildssong.com/2010/

    This is my first theme and I've built it with Kubric as a starting point.

    Can someone point me in the right direction?? Is there a plugin that will work for this?

    Is there a way to do this?

  2. tugbucket
    Member
    Posted 1 month ago #

    <div id="announcement">
        <div class="orange_tag">
          <h2>Announcement</h2>
        </div>
    <?php query_posts("posts_per_page=1&category_name=announcements"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    </div>

    that should query the category of "announcements" and display the most recent post from it. It won't post the date, time, title etc... just the post body.

  3. rickmesser
    Member
    Posted 1 month ago #

    SWWWEEEETTT!!! Worked like a charm man! Thank you so much!

Reply

You must log in to post.

About this Topic