Adding a View Comment Link in the Dashboard

There’s one thing that I find really annoying in WordPress. For every post, page, custom post type, in the posts list there’s a link to view that specific post. It shows when you hover over the post title, but there’s not a View Comment link in the comments list. Why not?

I don’t know, maybe it’s a good core patch idea, but for the moment, here is a snippet that you can use to add such link.

Add this code to your functions.php file in wp-content/themes/your-child-theme-name/ at the end of the file:


/**
* Print a View Comment link in the comments list in the admin.
*
* @param array $actions
* @return array
*/
function custom_view_comment_action( $actions ) {
global $comment;
if ( $comment->comment_type !== '' ) {
return $actions;
}
$actions['view_comment'] = '<a href="' . get_comment_link( $comment ) . '" title="View Comment" target="_blank">View Comment</a>';
return $actions;
}
add_filter( 'comment_row_actions', 'custom_view_comment_action' );

view raw

functions.php

hosted with ❤ by GitHub

Once you added it, save the file and go to Dashboard > Comments, hover over the content of a comment from that list and you will see the View Comment link after the Trash link.


More Posts That You Might Like…


One response to “Adding a View Comment Link in the Dashboard”

  1. Thank you so much for this post . This is really helpful,

Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: