Ready to get started?Download WordPress


What am I doing wrong? (loop problem) (1 post)

  1. Funktipus
    Posted 7 years ago #

    Hi, my English is not that good, but I'll give it a try.

    I've got some problems with my loop.
    My frontpage is showing the latest post and underneath that my 5 recent posts before the first one.
    Only shown by title (and permalink) in a special <div>.

    / Latest post (id=6) /

    / post id=5
    / post id=4
    / post id=3
    / post id=2
    / post id=1

    OK, works fine, but I want the date of those recent posts before the title.

    My div for those 5 latest post:
    <div id="recent">
    <h2>Recente blogposts</h2>
    $posts = get_posts('numberposts=5&offset=1');
    foreach ($posts as $post) :
    <li><span class="recpost"><?php the_date('','',''); ?></span> — <a href="<?php the_permalink(); ?>"><?php the_title() ?></a></li>

    <?php endif; ?>

    The problem is; if I'm using this one, only the first <li> is shown with the date:

    / Latest post (id=6) /

    / -date- post id=5
    / post id=4
    / post id=3
    / post id=2
    / post id=1

    What am I doing wrong?

Topic Closed

This topic has been closed to new replies.

About this Topic