DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Wouldn’t it be nice if you were able to mark a comment as spam, or even delete it, from your blog, without visiting your WordPress dashboard? If you’re interested, read on, you’ll probably not regret it 😉

First, we have to create the function. Paste the code below on the functions.php file from your theme. If that file doesn’t exists, create it.

function delete_comment_link($id) {
  if (current_user_can('edit_post')) {
    echo '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">del</a> ';
    echo '| <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>';

Then, edit your comments.php file. Add the following code where you want it to appear. It must be within the comment loop. On most themes, you’ll find a edit_comment_link() declaration. Add the code just after.


Credits goes to Joost de Valk for this awesome recipe!


  1. Hi, great code! Thx!
    Is there a way to implement this fonctionality for the one (an author) who posted the comment?

    Thank you!

  2. Nice tip!

    I will add this to my functions.php files.

    Thank you.

Leave a Comment

Your email address will not be published. Required fields are marked *