Fixing the Post Title Link when Editing Comments

This has bugged me for years. I can’t believe it took me this long to fix it. When I’m moderating comments, people will often reference something in the post or another comment.

At the top of the page it says Comments on “Post Title Here”. No matter how many times I’ve clicked it, I always expect that clicking the post title will take me to the post on the frontend, so I can quickly review the post or comments. But it’s actually an edit post link.

I don’t see the use case for assuming people want to edit their post after receiving a comment, but luckily everything in WordPress is filterable. Add this to your theme’s functions.php file or core functionality plugin:

* Fix the Post Title Link on Edit Comments
* @author Bill Erickson
* @link
* @param string $link, the edit post link
* @param int $post_id, the post ID
* @param string $context, The link context. If set to 'display' then ampersands are encoded.
* @return string $link, modified edit post link
function be_fix_post_title_link_on_edit_comments( $link, $post_id, $context ) {
if( ! is_admin() )
return $link;
$screen = get_current_screen();
if( $screen->base == 'edit-comments' )
$link = get_permalink( $post_id );
return $link;
add_filter( 'get_edit_post_link', 'be_fix_post_title_link_on_edit_comments', 10, 3 );
view raw functions.php hosted with ❤ by GitHub

First, we’re making sure we are in the admin area, since get_current_screen() doesn’t work on the frontend and get_edit_post_link() can appear on the frontend too (ex: the admin bar). We then check if the current screen is ‘edit-comments’, and if it is we replace the edit link with the post’s permalink.

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions


Leave A Reply