Deleted a post by mistake? Don’t panic. It can happen to anyone and it had happened to me many times. Happened is happened, but is there a way to recover/restore deleted post in WordPress? Fortunately, there are few options.
4 Ways to Recover/Restore Deleted Post in WordPress
Look into Trash
If you had deleted a post, WordPress moves it to Trash folder. Login to WordPress, click on
All Posts and look out for
'Trash' link at the top. Click on it to view all deleted posts. To restore the post, just move the mouse on top of the post title and you will find “
Restore” link. Click it and you are done.
What if you had flushed out posts from Trash as well? Ahh! You did that, seriously? Try the below options then.
Recover from Backups
Do you take a backup of your site? Of course, you must be doing that (if not, learn from the mistake and backup WordPress database regularly). Just go ahead and look out for older backup (probably the closest date on which the post was published).
Step 1: Open the WordPress SQL backup file (say backup-oct-2017.sql) and search for deleted post.
# vim backup-oct-2017.sql
Feeling lucky? Then you should be able to get the post ID of the deleted post from the SQL backup file. Now, import the SQL file into a test database as shown below:
mysql> CREATE DATABASE recover_post_db; mysql> use recover_post_db; mysql > source backup-oct-2017.sql; mysql> SELECT * FROM wp_posts WHERE ID=<deleted_post_id>;
Copy the post content from the query output and create a new post.
Search Google Cache
The next option is to try searching the deleted post in Google cache. If you remember the title or keywords of the deleted post, then head on to Google and search for it. For example, if the deleted post title was “Missing Delete option under a category in WordPress?” (you know what, this is the title of the post which I had deleted accidentally), then you can try searching it in Google as shown in the below image. Remember to append your domain name at the end of the search string to prevent seeing posts from other websites. Now click on the tiny pull down menu and select
Cached to view the page cached by Google.
Look into RSS Feeds
If you are publishing RSS feeds, then you may want to check if your RSS reader have a copy of the deleted post. May be, who knows? But its worth checking isn’t?