WordPress.org

Ready to get started?Download WordPress

Forums

Get posts in a category in floated div (2 posts)

  1. pewter
    Member
    Posted 6 years ago #

    I'm using WP as a light CMS and have static front page with slug "home". I want the 3 most recent excerpts from posts in the "news" category to be displayed on the front page with links to the full posts on the "blog" Page. I'm using conditionals in my sidebar to call what I want on the other Pages of the site. Could you please take a look and see what I'm not doing right since nothing at all is showing in the Home's sidebar? I was hoping the posts would at least show up and then I could figure out how to dispaly just excerpts, but nothing's showing (but they are showing on the "blog" Page). The other Pages' sidebars work, but then again they all have just html.

    sidebar.php code:

    <div id="sidebar">
    <?php if(is_page(home)) : ?>
    <p>
    query_posts('category_name=news');

    //as $wp_query is reinitialised, let's run the_loop
    if (have_posts()) :
    while (have_posts()) : the_post();
    the_title();
    endwhile;
    endif;</p>

    <?php endif; ?>

    <?php if(is_page(about)) : ?>

    image and paragraph go here

    <?php endif; ?>

    <?php if(is_page(work)) : ?>

    paragraphs and links go here

    <?php endif; ?>

    <! --etc for other pages in my navigation -->

    </div>

  2. pewter
    Member
    Posted 6 years ago #

    Could anyone please take a look at this and offer some help? I would appreciate it.

    It doesn't matter what I enter in the (home) argument - nothing will show. I'm at a loss.

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic