Fix “Cannot Locate Deleted File In WordPress But Exists”

Aug 6, 2020

Fix “Cannot Locate Deleted File In WordPress But Exists”

Aug 6, 2020

Deleted a file on your WordPress site and now regret it? We’ve all been there. 

You may have deleted an unwanted file but now you need it. Or in worse cases, you may have accidentally deleted a file that was required by a theme and plugin. Deleting critical files leads to your site breaking or the plugin or theme malfunctioning.

Luckily, there are multiple ways in which you can retrieve a deleted file on your WordPress site. In this guide, we’ll show you how to locate those deleted files and restore them.

TLDR – 

Trying to recover deleted files in WordPress is not uncommon. You need to access File Manager in the cPanel of your hosting account. Here, you can locate and restore the file. 

If you have a backup copy of your website, you can restore your backup and that will restore your deleted file as well. Use a reliable backup solutionsuch as BlogVault that will take backups of your site regularly. When you need to recover deleted files, you can either restore your backup or download your backup to find a copy of your file.

 

How To Locate Deleted WordPress Files 

 

There are different types of WordPress files on your site. Some relate to posts and pages, some contain themes and plugins, others contain configurations and settings. 

If you’ve deleted a post or a page on WordPress, you should find it in the Trash folder. This can be easily accessed from the wp-admin panel.

 

Check if the file exists in Trash

There are also times when you might’ve deleted a media file from a page or post. In these cases, you can still find it in your WordPress media library. 

But if you’ve deleted media files from the media library itself or any important files of a WordPress plugin or theme, or even the core installation, then you may not be able to find these deleted files using the wp-admin panel and if you try accessing the deleted files, you would see the error “Cannont locate deleted file in WordPress but exist”.

In cases like this, you need to go behind the scenes of your WordPress site to locate the files and restore them. 

We’ll show you how to do this, but first, we must caution you that going into the backend of a WordPress site is risky. Any misstep here can break your site or cause damage to your site. So before you begin the process, take a complete backup of your WordPress site. 

You can get a backup in under a few minutes using a plugin like BlogVault. Activate the plugin on your site, and enter your email address and Get Started. BlogVault will automatically take a backup for you and store the copy safely. If anything goes wrong during this process, you can restore your backup in a single click. 

That said, follow the instructions below to locate your deleted files on WordPress:

Step 1: Log in to your WordPress hosting account and access cPanel.

 

Log In to Your WordPress Hosting

Step 2: Go to File Manager and select the folder called public_html. (If you named your website’s folder something else, select that folder.) 

 

Go to file manager

Step 3: Inside, you’ll see an option called View Trash. You can click on this to view all your deleted files here.

 

Check trash to locate file with "Cannot locate file in wordpress but exists" error

If you cannot see the View Trash option, look for a folder called .trash. Your site’s deleted items can be found inside this folder.

 

Check for .trash

Once you’ve located the files you want here, we show you how to restore these files next.  

 

How To Retrieve Deleted Files In WordPress That Still Exist?

 

There are multiple ways to restore your deleted files. If you’ve located your files using the method we’ve detailed above, it’s easy to restore them using cPanel. We’ve detailed this method first. 

In case you weren’t able to locate the deleted files, there are more ways in which you can find and restore your deleted WordPress files. So if the cPanel method isn’t for you, jump ahead to the alternative methods.

 

1. Restore Deleted Files Using cPanel

 

Once you’ve located the files using the method we entailed above, it’s easy to restore them to your site. 

Step 1: Select the file or folder you want to restore. 

Step 2: The option Restore on the top menu bar will be enabled now. You’ll see it change from grey to black. Simply click on Restore to get your file back on your WordPress site.

 

Select the file and click on restore

That’s it. You’ve successfully restored your deleted WordPress file. You can visit your WordPress site to check if you can see the file now.

If this method didn’t work, there’s still hope. We have a few more options for you to try. Let’s take a look.

 

2. Restore Backup To Retrieve Deleted WordPress Files 

 

One of the simplest ways to retrieve old files and deleted content is to restore your backup copy, if you have one. 

If you use a plugin to backup your WordPress site, most plugins allow you to restore your website easily. Look for help documents from the backup services or search for videos that’ll show you how to restore using that service. If you find the restoration process too difficult or daunting then it’s best to get help from the service provider.

If your site is backed up by an automated backup plugin like BlogVault, Backup Buddy, or UpdraftPlus, the restore process is simple. We’ve detailed the restoration process for BlogVault below but other plugins will most likely follow a similar process:

  1. Visit the BlogVault dashboard, under Backups, there is an option to restore your WordPress website. 
  2. You simply need to enter your FTP credentials to restore your backup copy. 

 

Restore using Backup Plugin

  1. You can also test your backup first to see if the restore process would work in retrieving the deleted file.

 

Test restore your backup to see if the backup version has the file you need

By test restoring your backup, you can make sure that the backup copy has the deleted files and that the process works. Only then you can restore your backup to your live site.

Now, this solution may not work if you deleted the file a long time ago. Restoring an old backup copy of your site means you’ll lose new content. 

In this case, you can download the backup file to your computer. A zip file will download to your computer. Extract it and look for the file you deleted on your WordPress site. 

 

Download the backup once you are sure of the verison

If you don’t have a WordPress backup with a plugin, check with your web hosting provider if they maintained a backup copy of your WordPress site. Depending on your web hosting plan, you might be eligible for automated daily backups. If you manage to secure a copy of your website from your host, you can use it to search for your deleted file. 

The drawback here is you would need to know where the file belongs and manually upload it to the right location using cPanel. 

Also Read: How to fix WordPress keeps logging me out?

 

3. Alternative Methods To Retrieve Deleted WordPress Files 

 

We know there are times where cPanel restore or backup restore fails. In these cases, here are a few tips that might be helpful in restoring your deleted WordPress files:

  1. If you’ve accidentally deleted a WordPress core file, try reinstalling or updating WordPress on your site. When you do this, WordPress will recreate the core files. We’ve detailed the steps on updating WordPress manually. The same steps would apply to reinstall WordPress. 
  2. For plugins and themes, you can attempt to reinstall or update a plugin or theme. This might restore the missing file. 
  3. If you’ve lost old content, media, posts, or pages, you can try to retrieve it using search engine caches. Search for the page using the following URL:
  • site:yourdomain.com your query

Replace yourdomain.com with the name of your WordPress website, and your query with the content you are looking for.

For example, if you were looking for an old post called ‘How to write content’ on a website called content.com, you would enter the following into Google’s search bar.

  • site:content.com how to write content

If the page pops up, you can click on the arrow pointing downwards next to your domain name to get a dropdown menu. Here, you will see the Cached option.

 

Fetch cached version of your page

 

When you select Cached, Google will display a snapshot of the page as it appeared on a particular date in the past. 

 

Try searching for the file you need on the cached page

 

Using these cached pages, you can try to recover old content, media files, and comments.

  1. You can also try to retrieve deleted content using a tool called the Wayback Machine. It takes snapshots of WordPress sites at random intervals. 

Visit the website, enter your domain name, and Wayback Machine will display a calendar if your website was archived by them. The highlighted dates indicate that a snapshot of your website was created.

 

You can also access wayback machine to retrieve the file you need

 By clicking on the highlighted date, you can view a snapshot of your website as it was on that date.

And with that we have come to an end on locating and restoring deleted WordPress files. 

 

 

Final Thoughts

 

When running a WordPress site, mistakes are bound to be made. We accidentally delete files or change settings. Botched updates or installing a new plugin end up breaking the site.

It’s best to be prepared for any untoward incidents by always maintaining backup copies of your WordPress site. The easiest and most efficient way to backup your site is to use a reliable plugin like BlogVault. 

Once activated on your site, your website’s backups are scheduled and will automatically run at regular intervals. So you can be sure a copy of your site and all its files and content is stored safely. 

When things go wrong, you can quickly restore your backup and get your site back to normal in a few minutes. 

Backup Your WordPress Site With BlogVault!

Cannot locate deleted file feature
Share via
Copy link