How to Add ‘Edit All Comments’ Link to WordPress Posts

How do you edit all 100 comments on your WordPress posts? Probably you go to the WordPress Admin to find the post, then see the number of comments beside the post, then click it to see the screen to edit all the comments on the posts. Or you click the single Edit link beside each comment individually.

Just as front end editing makes editing faster – would it not be easier if there was a link which would take WordPress admin/editors directly from the web page to the ALL comments moderation screen. We added this code is our WordPress theme which allows logged in admins to reach the comment moderation links in one click!

Edit All Comments

Traditionally you need to go to WordPress admin > All Post > Post > Comments Count Link.

comments count

Clicking on the comments takes you to the ALL Comments Edit Screen, where you can moderate comments quickly and deal with spam comments faster.

comments edit screen

Edit All Comments Link

I wanted to share a screenshot of what I see when I view the post.

edit comments link

Normal site visitors will not see those 2 buttons to ‘Edit Current Post’ and ‘Edit All Comments’ – it is only visible to logged in Admins on our site.

Here is the code we use

<?php 
if (is_user_logged_in() || current_user_can('edit_post')) { 
?>

<a  href="https://www.quickonlinetips.com/archives/wp-admin/post.php?post=<?php the_ID(); ?>&amp;action=edit">Edit Current Post</a>

<a href="https://www.quickonlinetips.com/archives/wp-admin/edit-comments.php?p=<?php the_ID(); ?>" target="_blank">Edit All Comments</a>

<?php } ?>

The first line checks to see the user is logged in and has rights to edit the post. Then next is the Edit Post button which you probably already have in your theme at some place. The next code adds the ‘Edit All Comments” link.

Where to add the code? You can add it to the single.php or content.php file, depending of your WordPress theme, where you want the code to appear.

How did we make those cool buttons? They are made easily with Bootstrap theme and Font Awesome – both essential elements of modern web design.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.