2012-05-02 54 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()

相關問題