Get the date of a post for each post (2 posts)

  1. ronnyrook
    Posted 3 years ago #

    Hello WordPress users,

    I'm currently building a website where I would like to display the date of a post on the hompage.

    Currently I'm using the following code to do this:

    $args = array( 'numberposts' => 2, 'category' => 2  );
            $postslist = get_posts( $args );
    foreach($postlist as $post) :
         setup_postdata($post); ?>
         <?php the_date(); ?> , <?php the_author(); ?>
    <?php endforeach;

    But this code is only working for the first post.
    The first post displays:
    april 1, 2013, admin

    But all the other posts displays:
    , admin

    I can't find out what is going wrong here.
    Someone who can help me out?

  2. Michael
    Forum Moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic