
如何使用PHP函数get_posts来构建文章列表
wp_update_comment_count ( $post_id, $do_deferred = false )
更新文章的评论数。
当$do_deferred为false(默认为false),并且评论已经被设置为deferred,文章_id将被添加到一个队列中,该队列将在稍后的日期被更新,每个文章ID只更新一次。
如果评论没有被设置为推迟,那么帖子将被更新。当$do_deferred被设置为 “true “时,那么所有以前被推迟的文章ID将和当前的$post_id一起被更新。
function wp_update_comment_count( $post_id, $do_deferred = false ) { static $_deferred = array(); if ( empty( $post_id ) && ! $do_deferred ) { return false; } if ( $do_deferred ) { $_deferred = array_unique( $_deferred ); foreach ( $_deferred as $i => $_post_id ) { wp_update_comment_count_now( $_post_id ); unset( $_deferred[ $i ] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ } } if ( wp_defer_comment_counting() ) { $_deferred[] = $post_id; return true; } elseif ( $post_id ) { return wp_update_comment_count_now( $post_id ); } }