Title: php loop help needed &#8211; orderby
Last modified: August 19, 2016

---

# php loop help needed – orderby

 *  Resolved [La M](https://wordpress.org/support/users/lady_moocher/)
 * (@lady_moocher)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/php-loop-help-needed-orderby/)
 * Hi
 * I have this latest news box on my home page. It’s meant to output the published
   date and excerpt text of the latest 3 posts with the news category.
 * It’s working okay, but it only outputs the date of the first item in the list
   when news stories are published on the same date. How can I amend the code so
   that it always outputs the date?
 * Thanks
 * <h3>Latest news</h3>
    <div>
 * <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID =
   = $do_not_duplicate ) continue; update_post_caches($posts); ?>
 * <?php $postslist = get_posts(‘numberposts=3&order=DEC&orderby=date&cat=6’);
    
   foreach ($postslist as $post) : setup_postdata($post); ?> <img src=”<?php bloginfo(‘
   url’); ?>/articles/wp-content/images/arrow_white.gif” /> <?php the_date(); ?>:
   <?php the_title(); ?> <?php the_excerpt(); ?>
 * <?php endforeach; ?>
 * <?php endwhile; endif; ?>
 * </div>
    </div>

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/php-loop-help-needed-orderby/#post-997839)
 * The Codex article, [the_date()](http://codex.wordpress.org/Template_Tags/the_date),
   explains why you should use the [template tag](http://codex.wordpress.org/Template_Tags),
   [the_time()](http://codex.wordpress.org/Template_Tags/the_time), for that situation.
 *  Thread Starter [La M](https://wordpress.org/support/users/lady_moocher/)
 * (@lady_moocher)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/php-loop-help-needed-orderby/#post-997892)
 * Brilliant, thanks Michael – works a treat.

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

The topic ‘php loop help needed – orderby’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [La M](https://wordpress.org/support/users/lady_moocher/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/php-loop-help-needed-orderby/#post-997892)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
