有沒有一種簡單的方法可以獲取 wordpress 頁面的“最新評論日期”?
對于頁面本身,有一個簡單的解決方案,如下所示:
get_the_date('Y-m-d', $post->ID)
例如,這對我不起作用(特別是因為我也無法定義最后一條評論):
get_comment_date( 'Ymd', $post->ID);
而我的陣列方式不起作用。“ comment_count”很好,但“ get_comment_date( 'd\/m\/Y' )”對于所有頁面來說總是相同的日期 - 為什么?
$args = array(
'post_id' => $post->ID,
'posts_per_page' => 10,
'post_type' => 'page',
'orderby' => 'date',
'category_name' => 'MyName');
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<?php echo '<div hljs-string">'d\/m\/Y' ) . '"><span>'. $comments_count .'<span></div>'; ?>
<?php endforeach; ?>
uj5u.com熱心網友回復:
如果我理解正確的話,您就是在嘗試獲取特定頁面的最新評論。所以,我會使用
如果這就是您要找的,請告訴我!
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/364213.html
標籤:php WordPress的 自定义wordpress-pages
