Nicola Mustone

Happiness Lead @ Automattic



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.

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

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

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: