2013-08-03 70 views
0

在類別頁面上顯示特定類別的職位,標題和發佈日期。問題在於它只獲取第一個列表項的日期,而另一個列表項則返回空白。WordPress的:在類別頁面上獲取發佈日期

這裏是我的代碼:

<div class="post-date"> 
    <?php the_date(); ?> 
</div> 

not getting published date for other posts

我怎麼能顯示後發表日期與每個帖子標題?

回答

2

使用此

<?php the_time('F j, Y \a\t g:i a'); ?> or 

<?php the_time(get_option('date_format')); ?> 

當有當天在發表了頁面上的多個職位,the_date()只顯示後的第一個日期(即the_date的第一個實例()) 。要重複在同一天發佈的帖子的日期,您應該使用具有日期特定格式字符串的模板標記the_time()。

+1

正如[食品](http://codex.wordpress.org/Function_Reference/the_date),您可以用'提到<?PHP the_time (get_option( 'DATE_FORMAT')); ?>'自動使用與'the_date()'相同的日期格式,這是在您的WordPress設置中配置的日期格式。如果WordPress管理員更改日期格式,這有助於保持整個網站的一致性。 –

+0

非常感謝 –

1

您可以嘗試在後續獲得那個職位日期

<?php the_time(get_option('date_format')); ?> 
相關問題