使用 get_posts 显示 wordpress 帖子 - 第一个帖子不显示日期 [英] Display wordpress posts using get_posts - first post shows no date
问题描述
您好,我正在使用 get_posts 抓取所有标记为新闻"的帖子,并将它们显示在给定页面上.我正在使用 the_date() 来获取日期,但奇怪的是第一篇文章没有显示日期,而此后的所有文章都显示日期很好.我也使用了这个相同的代码在另一个页面上显示标记为博客"的帖子,但它们工作正常.
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.
页面如下:http://appshare.nsdesign7.net/news/
还有另一个页面使用了相同的代码但工作正常:http://appshare.nsdesign7.net/blog/
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 } ?>
推荐答案
尝试使用:
echo get_the_date();
阅读特别说明:http://codex.wordpress.org/Template_Tags/the_date
这篇关于使用 get_posts 显示 wordpress 帖子 - 第一个帖子不显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!