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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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' ); |
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.
Leave a Reply