wp_queue_comments_for_comment_meta_lazyload

函数
wp_queue_comments_for_comment_meta_lazyload ( $comments )
参数
  • (WP_Comment[]) $comments Array of comment objects.
    Required:
定义位置
相关方法
wp_queue_posts_for_term_meta_lazyloadwp_update_comment_count_nowwp_latest_comments_draft_or_post_titlepost_comment_meta_box_theadpost_comment_meta_box
引入
4.5.0
弃用
-

wp_queue_comments_for_comment_meta_lazyload: 这个函数用来排队评论,以便懒惰地加载评论元数据。它通过只在需要时加载评论元数据来提高网站的性能。

为元数据的懒加载队列评论。

function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
	// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
	$comment_ids = array();
	if ( is_array( $comments ) ) {
		foreach ( $comments as $comment ) {
			if ( $comment instanceof WP_Comment ) {
				$comment_ids[] = $comment->comment_ID;
			}
		}
	}

	if ( $comment_ids ) {
		$lazyloader = wp_metadata_lazyloader();
		$lazyloader->queue_objects( 'comment', $comment_ids );
	}
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-07 10:33:40

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: