0

I want to add my own buttons to the comments editor table:

enter image description here

I tried to understand what happens in wp-admin/comment.php , edit-comments.php, includes/class-wp-comments-table-lists.php etc. but I couldn't figure it out.

0

You can use two filters for that:

  • manage_edit-comments_columns - to add a column header on comments table
  • manage_comments_custom_column - to add the content of each row for that column

So you would have something like this:

function myplugin_comment_columns( $columns )
{
    $columns['my_custom_column'] = __( 'My Category' );
    return $columns;
}
add_filter( 'manage_edit-comments_columns', 'myplugin_comment_columns' );

function myplugin_comment_column( $column, $comment_ID )
{
    if ( 'my_custom_column' == $column ) {
        echo '<a href="' . admin_url('/my-action.php?id=' . $comment_ID) . '">My button</a>';
    }
}
add_filter( 'manage_comments_custom_column', 'myplugin_comment_column', 10, 2 );
| improve this answer | |
  • Hi, thanks for your help ! But where do I put it? :) – J. Doe Jun 30 '17 at 13:10
  • You can put it on functions.php of your theme or create a plugin with this. If you're just using a 3rd party theme and don't want to create a plugin, you can always create a child theme from your current theme and put this code inside that functions.php. – dbeja Jun 30 '17 at 13:12
  • What do you have on your side? – dbeja Jun 30 '17 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.