Queue comment meta for lazy-loading.
Parameters
$comment_idsarrayrequired- List of comment IDs.
Source
function wp_lazyload_comment_meta( array $comment_ids ) { if ( empty( $comment_ids ) ) { return; } $lazyloader = wp_metadata_lazyloader(); $lazyloader->queue_objects( 'comment', $comment_ids ); } Changelog
| Version | Description |
|---|---|
| 6.3.0 | Introduced. |
In this example, the
wp_lazyload_comment_metafunction takes an array of comment IDs and iterates through them. For each comment ID, it simulates lazyloading by fetching comment metadata using theget_comment_metafunction. The metadata is then processed, and in this case, it’s simply printed to the screen. You can replace the print statements with your desired processing logic. The example usage at the end demonstrates how to call the function with an array of comment IDs.