WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Two get_post no date on 2nd (2 posts)

  1. EUR1LEC
    Member
    Posted 3 years ago #

    Hi!

    I'm having a little problem with get_post

    I have two get_post on my index and the second one dosen't display the date. Only the first query. Although it shows the permlink on the second one.

    Heres my code:

    <div id="posts">
            <div id="latest-news">
                <div class="media-top"></div>
                <div class="media-bg">
                    <h2>Latest news</h2>
    
          <?php
     $lastposts = get_posts('numberposts=5&category=1&order=ASC&orderby=date');
     foreach($lastposts as $post) :
        setup_postdata($post);
     ?>
    
       <p class="date"><?php the_date(); ?></p>
      <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
    
     <?php endforeach; ?>
                    <br/><br/>
                    <a href="/news" class="highlight">View all news</a>
    
                </div>
                <div class="media-end"></div>
            </div>     <!-- END #LATEST-NEWS -->
    
            <div class="hspaceFix"></div>
    
            <div id="latest-media">
                <div class="media-top"></div>
                <div class="media-bg">
                    <h2>Latest media</h2>
    
                      <?php
     $mediaposts = get_posts('numberposts=5&category=-1&order=ASC&orderby=date');
     foreach($mediaposts as $post) :
        setup_postdata($post);
     ?>
    
       <p class="date"><?php the_date(); ?></p>
      <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
    
     <?php endforeach; ?>
    
                    <br/><br/>
                    <a href="/media" class="highlight">View all media posts</a>
    
                </div>
                <div class="media-end"></div>
    
            </div>   <!-- END #LATESTMEDIA-MEDIA -->
        </div>

    Any ideas why it isen't working?

  2. EUR1LEC
    Member
    Posted 3 years ago #

    Solved by using <?php the_time(get_option('date_format')); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.