2012-03-27 75 views
0

我正在使用一個插件,它將一些帖子從一個標籤分組到另一個帖子中。我想爲這些帖子添加human_time,但我在下面使用的方法只是調用父帖子的時間。human_time發佈帖子內的帖子

if ($date) { 
    $output .= __('on ', 'posts-by-tag'); 
    $output .= mysql2date(get_option('date_format'), $post->post_date) . ' at ' ; 
    $output .= mysql2date(get_option('time_format'), $post->post_date) . '<span class="the-times">' ; 
    $output .= human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago</span></p></div>' ; 

兩個中間輸出正常工作,只是最後一個沒有。最後一次輸出中需要的變化才能使其起作用?我猜這與$ post->有關,但我不確定正確的結構。

回答

2

如果這不是在「The循環」你必須瞄準的帖子ID在喜歡你get_the_time功能:

$output .= human_time_diff(get_the_time('U',$post->id), current_time('timestamp')) . ' ago</span></p></div>' ; 
+0

知道會是這樣的,謝謝:) – Jim 2012-03-27 17:17:18