Title: wp_lazyload_comment_meta
Published: August 8, 2023
Last modified: August 20, 2026

---

# wp_lazyload_comment_meta( array $comment_ids )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#wp--skip-link--target)

Queue comment meta for lazy-loading.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#parameters)󠁿

 `$comment_ids`arrayrequired

List of comment IDs.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#source)󠁿

    ```php
    function wp_lazyload_comment_meta( array $comment_ids ) {
    	if ( empty( $comment_ids ) ) {
    		return;
    	}
    	$lazyloader = wp_metadata_lazyloader();
    	$lazyloader->queue_objects( 'comment', $comment_ids );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/comment.php#L592)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment.php#L592-L598)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_metadata_lazyloader()](https://developer.wordpress.org/reference/functions/wp_metadata_lazyloader/)`wp-includes/meta.php` |

Retrieves the queue for lazy-loading metadata.

  |

| Used by | Description | 
| [wp_queue_comments_for_comment_meta_lazyload()](https://developer.wordpress.org/reference/functions/wp_queue_comments_for_comment_meta_lazyload/)`wp-includes/deprecated.php` |

Queues comments for metadata lazy-loading.

  | 
| [_prime_comment_caches()](https://developer.wordpress.org/reference/functions/_prime_comment_caches/)`wp-includes/comment.php` |

Adds any comments from the given IDs to the cache that do not already exist in cache.

  | 
| [WP_Comment_Query::get_comments()](https://developer.wordpress.org/reference/classes/wp_comment_query/get_comments/)`wp-includes/class-wp-comment-query.php` |

Get a list of comments matching the query vars.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/?output_format=md#comment-content-6618)
 2.   [Huzaifa Al Mesbah](https://profiles.wordpress.org/huzaifaalmesbah/)  [  3 years ago  ](https://developer.wordpress.org/reference/functions/wp_lazyload_comment_meta/#comment-6618)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_lazyload_comment_meta%2F%23comment-6618)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_lazyload_comment_meta%2F%23comment-6618)
 4.     ```php
        /**
         * Lazyloads metadata for a list of comment IDs.
         *
         * @param array $comment_ids Array of comment IDs.
         */
        function wpdocs_lazyload_comment_meta( array $comment_ids ) {
            foreach ( $comment_ids as $comment_id ) {
                // Simulate lazyloading by fetching comment metadata only when needed.
                $comment_meta = get_comment_meta( $comment_id );
    
                // Process the comment metadata.
                // For demonstration purposes, we'll just print it here.
                echo 'Lazyloaded metadata for comment ID ' . $comment_id . ':';
                foreach ( $comment_meta as $meta_key => $meta_values ) {
                    echo $meta_key . ': ' . implode( ', ', $meta_values );
                }
            }
        }
    
        // Example usage
        $comment_ids_to_lazyload = array( 1, 2, 3, 4, 5 );
        wpdocs_lazyload_comment_meta( $comment_ids_to_lazyload );
        ```
    
 5. In this example, the `wp_lazyload_comment_meta` function takes an array of comment
    IDs and iterates through them. For each comment ID, it simulates lazyloading by
    fetching comment metadata using the `get_comment_meta` function. 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.
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_lazyload_comment_meta%2F%3Freplytocom%3D6618%23feedback-editor-6618)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_lazyload_comment_meta%2F)
before being able to contribute a note or feedback.