The manage_comments_custom_column WordPress action allows you to display custom content in a single row of a custom column in the comments list table.
Usage
add_action('manage_comments_custom_column', 'your_custom_function', 10, 2); function your_custom_function($column_name, $comment_id) { // your custom code here }
Parameters
$column_name
(string): The custom column’s name.$comment_id
(string): The comment ID as a numeric string.
More information
See WordPress Developer Resources: manage_comments_custom_column
Examples
Displaying the comment author’s email
Add the author’s email address in a custom column named “author_email”.
add_action('manage_comments_custom_column', 'display_author_email', 10, 2); function display_author_email($column_name, $comment_id) { if ('author_email' === $column_name) { $comment = get_comment($comment_id); echo $comment->comment_author_email; } }
Displaying the comment’s word count
Add the word count of a comment in a custom column named “word_count”.
add_action('manage_comments_custom_column', 'display_comment_word_count', 10, 2); function display_comment_word_count($column_name, $comment_id) { if ('word_count' === $column_name) { $comment = get_comment($comment_id); $word_count = str_word_count($comment->comment_content); echo $word_count; } }
Displaying the comment’s country flag
Add the commenter’s country flag in a custom column named “country_flag”.
add_action('manage_comments_custom_column', 'display_country_flag', 10, 2); function display_country_flag($column_name, $comment_id) { if ('country_flag' === $column_name) { // Get the commenter's country code (assuming it's stored as comment meta) $country_code = get_comment_meta($comment_id, 'country_code', true); if ($country_code) { echo '<img src="/flags/' . $country_code . '.png" alt="' . $country_code . '">'; } } }
Displaying the comment’s rating
Add the rating of a comment in a custom column named “rating”.
add_action('manage_comments_custom_column', 'display_comment_rating', 10, 2); function display_comment_rating($column_name, $comment_id) { if ('rating' === $column_name) { // Get the rating (assuming it's stored as comment meta) $rating = get_comment_meta($comment_id, 'rating', true); if ($rating) { echo $rating . '/5'; } } }
Displaying the comment’s featured status
Add the featured status of a comment in a custom column named “featured”.
add_action('manage_comments_custom_column', 'display_comment_featured_status', 10, 2); function display_comment_featured_status($column_name, $comment_id) { if ('featured' === $column_name) { // Get the featured status (assuming it's stored as comment meta) $featured = get_comment_meta($comment_id, 'featured', true); echo $featured ? 'Yes' : 'No'; } }