Skip to content

How to Retrieve WordPress Comments Accidentally Marked As Spam

How to Retrieve WordPress Comments Accidentally Marked As Spam published on 1 Comment on How to Retrieve WordPress Comments Accidentally Marked As Spam

WordPress doesn’t delete comments you mark as spam – they remain in the database to help train the spam catcher. If you accidentally mark a real comment as spam (or, perchance, a whole page of them), and you have access to phpMyAdmin, you can get it back pretty easily.

Standard disclaimers: This is for WordPress 2.5.1 – I don’t know if the database is organized in exactly this way in all previous versions, or whether they’re going to change it in later versions. Don’t do anything big with this without backing up your database, and don’t do it at all if the idea of messing around with MySQL by yourself scares you. I suspect there are plugins that’ll help you with comment recovery out there – go look for one if you’re worried you’ll mess something up. (But back up your database anyway. No, seriously. There’s a plugin for that.)

1) Go into phpMyAdmin. There’s a list of all your databases on the left. Click the name of your WordPress database.

If you didn’t name the database yourself or can’t remember what you named it, it’s probbbably called “wordpress” or “blog” or something. If you have a bunch of databases named something like that and you totally can’t remember, download your wp-config.php file via FTP (not via the browser) and open it in a text editor. The name will be in there.

2) There’ll be a list of all the tables in the database. One will be named wp_comments. In that table’s “Action” column, click the “Browse” icon (in phpMyAdmin 2.11.4, the first one on the left).

3) Here are your comments. They are ugly! If they’re so ugly as to be unreadable, click on “Structure” up at the top and select the checkboxes for comment_author, comment_author_email, comment_date, comment_content, and comment_approved, then click the “Browse” button at the bottom. This will show you the list with only those particular columns – much easier to deal with.

You can click on the column names at the tops of the columns to sort them – descending by comment_date is probably best. You navigate using the “>” and “>>” buttons and the page number boxes at the top and bottom.

You may have a lot of spam in here, so if the comments you killed weren’t brand new, I can’t really tell you how best to find them – you’ll have to experiment.

If you know what post the comment was in, you can try searching using the post ID. When you open a post for editing, the last number in the URL is that post’s ID number in the database. To find comments for a particular post, you can click on “Search” up at the top, scroll down to where it says Or Do a “query by example” (wildcard: “%”), put the comment ID number into the box labeled comment_post_ID, and click “Go.”

If you don’t know that, but can remember some of the content of the comment, you can search that way, too. The easiest way to use the search is to set the field you’re searching in (comment_content, comment_author, etc) to “LIKE %…%“, type in your query, and press “Go”.

4) When you find the comment(s) you want to resurrect, either click the “Change” button beside it (looks like a pencil in phpMyAdmin 2.11.4), or, if there are several of them, click their checkboxes, then click the “Change” button at the bottom.

Scroll down to find the textbox labeled comment_approved. It will say “spam” in it. Change this to “1.” If you’re editing several comments, you’ll need to scroll down and do this individually for each entry. When you’re done, click the button at the bottom saying “Go”.

5) Go to your WordPress comments management area, or the post(s) for the comment(s) in question. It/they should be back. Yay!

1 Comment