使用 get_posts 显示 WordPress 帖子 - 第一篇帖子不显示日期

2024-03-13

您好,我正在使用 get_posts 来获取所有标记为“新闻”的帖子并将其显示在给定页面上。我使用 the_date() 来获取日期,但奇怪的是第一篇文章没有显示日期,而此后的所有文章都显示日期。此外,我还使用了相同的代码在另一个页面上显示标记为“博客”的帖子,但它们工作正常。

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

这里还有另一个页面,使用了相同的代码,但工作正常:http://appshare.nsdesign7.net/blog/ 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();

Read 特别提示 on: http://codex.wordpress.org/Template_Tags/the_date http://codex.wordpress.org/Template_Tags/the_date

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 get_posts 显示 WordPress 帖子 - 第一篇帖子不显示日期 的相关文章

随机推荐