Hi am using get_posts to grab all posts tagged as ‘news’ and display them on a given page. I am using the_date() to get the date but what is weird is that the first post shows no date, whereas all posts after this display the date fine. Also I have used this identical code to show posts tagged as ‘blogs’ on another page, yet they work fine.
Here is the page:
http://appshare.nsdesign7.net/news/
Also here is the other page the same code is used on but works fine:
http://appshare.nsdesign7.net/blog/
<? $pageTitle = wp_title('',false,'');
if ($pageTitle == " News") { ?>
<?php $appsharenewspage = array( 'numberposts' => 10, 'order'=> 'ASC', 'orderby'=> 'title', 'category' => 3 );
$postslist = get_posts( $appsharenewspage ); foreach ($postslist as $post) : setup_postdata($post); ?>
<article class="newsstyle">
<span class="imagestyle"><?php the_post_thumbnail(array(120,120)); ?> </span>
<h3><?php the_title(); ?></h3>
<span class="date"><?php the_date(); ?></span>
<?php the_excerpt(); ?>
<div class="clear"></div>
</article>
<?php endforeach; ?>
<?php } ?>
Try using:
Read Special Note on: http://codex.wordpress.org/Template_Tags/the_date
the_date() is restricted to only show the date once per day. So if you have more then one post from the same day, it will only show on one of those posts.
Use the_time instead.
Try using
<?php echo get_the_date(); ?>
instead.the_date displays date if the post is published on the same day only.
Reference: http://codex.wordpress.org/Function_Reference/get_the_date
The date only occurs once per day. ie for 2 posts on the same day one will be without the date. It is a WP function. To get what you want replace with the php function get time. try to use
the_time()
instead ofthe_date()