Jump to content

Somthings Wrong With My Loop


lchosts

Recommended Posts

This is working right in the 1st and 3rd round through however the 2nd round it dosent return the date.... any ideas why? Im very new at this so sorry if its obvious <?php global $post; $args = array( 'numberposts' => 3, 'category' => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <div class="newstitle"><?php the_title(); ?></div><div class="newsdate"><?php the_date('d-m-y'); ?></div> <div class="newsinfo"><a href="'. get_permalink($post->ID) . '"><?php echo excerpt(30); ?></a></div> <?php endforeach; ?>

Link to comment
Share on other sites

This is for wordpress, is it? These aren't native PHP functions, so some people might not know what they're for.This is the line that should be displaying the date: the_date('d-m-y');If the date isn't appearing, then all I can suppose is that there is no value for it. Have you checked the wordpress documentation for that function to see what it means when the date is mising?

Link to comment
Share on other sites

Would I be correct in thinking that the 1st and 2nd items both have the same date, and 3rd one is different? If that's the case, you've probably run into this "feature" of the the_date() function:

SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.Use <?php the_time(get_option('date_format')); ?> to add the date set in the admin interface.
See http://codex.wordpress.org/Template_Tags/the_date for more info on this.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...