• Resolved aymie

    (@aymie)


    I’ve implemented an add-on which does the get the latest article, but I’m finding it a little tricky and it’s probably not what I need but….

    How do you display the latest article at the very top of your page without it repeating? What I mean is, I have a wordpress theme I designed, which uses two different box codes. The top one is COLOURED for the latest article and the one underneath (which repeats its code for the other articles) is white.

    I’d like the latest article to sit in the coloured box and all older articles to be in the white boxes below it.
    So far, the latest article repeats in both the colored box and the white box under it.

    I tried using the add-on but it only gave the title (even after following the instructions), without the article.

    Sorry if this sounds stupid, I’m new to WordPress AND I’ve checked the forum/support documents and I can’t find anything to do with it…I’ve even checked the layout forum….mind you it’s 5:30am here so I may have missed it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Eric Amundson

    (@sewmyheadon)

    Hey aymie,

    You may be looking for a Multiple Loop situation, where the top box only pulls the latest article and the other section has a loop that looks for all but the latest article.

    You may want to check out these articles:

    Thread Starter aymie

    (@aymie)

    Hmn, I read through them and now I’m thinking: “huh?”
    I understand the multiple loop topic, but it basically focuses on the latest article from a category e.g. special_category. But what if I don’t want to specify a category? I don’t know what I’m going to categorise an article under until I’m finished writing it up.
    Can it be done by specifying the_date or the_time as the latest article and not the category? Like this:

    (Rough example, probably way off)

    <?php query_posts(‘the_date=the_time(‘j F Y’)&showposts=1′); ?>

    Well, something like that…I guess it’s just confusing me because it specific to one category and not the date or time…

    Eric Amundson

    (@sewmyheadon)

    Hey Aymie,

    Yes, it can be done like that. I’m not a pro with this yet, but I tend to be able to get it to work with some fiddling.

    Check out Template_Tags/get_posts. It shows how to pass parameters with your get posts requests.

    I think with this and some more searching in the Codex, you should be able to get it working.

    Thread Starter aymie

    (@aymie)

    Ok, I got it working–so this topic is RESOLVED because I used a foreach post code and removed the while code. So it seemed to have worked…for now.

    I did this (in case anyone else has the same problem)


    <div id="post-latest" id="post-<?php the_ID(); ?>">
    <?php
    $posts = get_posts('numberposts=1');
    foreach($posts as $post) :
    setup_postdata($post);
    ?>
    <!-- do stuff here -->
    <?php endforeach; ?>
    <!-- more link etc. here -->
    <?php
    $posts = get_posts('numberposts=5&offset=1');
    foreach($posts as $post) :
    setup_postdata($post);
    ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <!-- do stuff here -->
    <?php endforeach; ?>

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Latest article WITHOUT repeat’ is closed to new replies.