2012-05-02 56 views
3

您好,我正在使用get_posts来抓取标记为'news'的所有帖子并将它们显示在给定页面上。我使用the_date()来获取日期,但奇怪的是,第一篇文章显示没有日期,而在此之后的所有文章显示日期罚款。此外,我使用这个相同的代码来显示在另一个页面上标记为'blogs'的帖子,但它们工作正常。使用get_posts显示wordpress帖子 - 第一篇文章显示没有日期

这里是页: http://appshare.nsdesign7.net/news/

另外这里的其他页面相同的代码上使用,但工作得很好: 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 } ?> 

回答

0

the_date()被限制为只显示日期每天一次。因此,如果您在同一天有多个帖子,则只会在其中一个帖子上显示。

改为使用the_time。

0

日期只出现每天一次。即在同一天的两个帖子中没有日期。这是一个WP功能。为了得到你想要的东西,用php函数取代时间。尝试使用the_time()而不是the_date()

相关问题