Delete Comment Link (3 posts)

  1. BlaenkDenum
    Posted 8 years ago #

    Hey guys. As of now, when I view comments on posts by going to the post directly, I see edit links on each comment so that I can easily edit it. However, I'd also like to have a delete link in case it's a muck up or something. I was trying to figure out how to construct a delete link but I wasn't able to because it needs some wpnonce parameter which I can't come up with. For example this is the URL that's on the edit comment page:


    The only thing I can't come up with is the wpnonce field. Or is there a function in wordpress that constructs the delete comment URL?

  2. BlaenkDenum
    Posted 8 years ago #

    I got it, just took the code from wp-admin/edit-comments.php:

    <?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    $url = clean_url(wp_nonce_url( "/wp-admin/comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ));
    echo "<a href='$url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . "</a> ";
    } ?>
  3. Anonymous
    Posted 8 years ago #

    Thank you, for literally being the only person alive to not only post a problem, but bother coming back with a solution. :)

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic