5 | | add_filter('the_comments', 'cache_all_comment_meta', 100); // using get_comments() |
6 | | add_filter('comments_array', 'cache_all_comment_meta', 100); // using Direct SQL in comments_template() |
7 | | function cache_all_comment_meta($comments) { |
8 | | $comment_ids = wp_list_pluck($comments, 'comment_ID'); |
9 | | update_meta_cache('comment', $comment_ids); |
10 | | return $comments; |
11 | | } |
| 5 | add_filter('the_comments', 'cache_all_comment_meta', 100); // using get_comments() |
| 6 | add_filter('comments_array', 'cache_all_comment_meta', 100); // using Direct SQL in comments_template() |
| 7 | function cache_all_comment_meta($comments) { |
| 8 | $comment_ids = wp_list_pluck($comments, 'comment_ID'); |
| 9 | update_meta_cache('comment', $comment_ids); |
| 10 | return $comments; |
| 11 | } |