• Hi,

    I got a problem… I’m doing a loop for my news and the date doesn’t want to show up on the first element… The date still here on the other ones..

    <?php
    
    // Get lastests news
    
    		global $post;
    
    		$myposts = get_posts('numberposts=2&orderby=post_date&order=desc&category=1');
    
    		foreach($myposts as $post) {
    
    			setup_postdata($post);		
    
    ?>
    
    <h3><img src="https://www.detailformation.com/images/fleche-date.gif" align="absmiddle" /> <?php  the_date('j F Y'); ?></h3>
    
    <strong><?= the_title(); ?></strong>
    
    <p><?= the_excerpt(); ?></p>
    
    <p align="right" style="text-align: right">
    
    <a href="<?= the_permalink(); ?>" title="<?= the_title(); ?>" class="plus">En savoir plus</a> <img src="https://www.detailformation.com/images/gris-fleche.gif" alt="" align="absmiddle" />
    
    </p>
    
    <?php } ?>

    Can some one tell me why I got this problem?

    Thx,
    Patrice

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php
    
    // Get lastests news
    
    global $post;
    $args = array(
    'numberposts' =>2,
    'orderby' => date,
    'order' => desc,
    'cat' => 1
    );
    
    query_posts($args);
    
    while(have_posts()) { the_post();
    
    ?>
    
    <h3><img src="https://www.detailformation.com/images/fleche-date.gif" align="absmiddle" /> <?php the_time('j F Y'); ?></h3>
    
    <?= the_title(); ?>
    
    <p><?= the_excerpt(); ?></p>
    
    <p align="right" style="text-align: right">
    
    " title="<?= the_title(); ?>" class="plus">En savoir plus <img src="https://www.detailformation.com/images/gris-fleche.gif" alt="" align="absmiddle" />
    
    </p>
    
    <?php } ?>
    Thread Starter Patrice Poliquin

    (@poliquinp)

    @quanxitung : This is actully working pretty fine! Can you explain to me why I should use the_time() instead of the_date() in this kind of loop?

    @poliquinp: working pretty fine is good. I used the_date(), i don’t forget it have problem what, since i use the_time().
    you can search the_date vs the_time to study.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘The date wont show in my loop’ is closed to new replies.