Here is the painful situation – I was tempted by a cool snippet somewhere on the internet and decided to add it to my functions.php file in WordPress to customize my theme. After studying the code for a while, I wanted to copy and paste that to my functions.php file – after ensuring that it is a clean and working code.
This was related to a post level customization which will show ‘Updated date’ instead of ‘Published date’.
However, after I pasted and saved my functions.php file, the inevitable happened – my site is now broken and I get an error that says PHP Parse error and the page cannot be displayed because of that – or famously called as White Screen of Death.
Well, that’s when it struck me that one should always test a site offline before doing experiments like these online.
If you are interested in reading more about this: Edited functions.php, didn’t get desired result, restotored php, can’t login now
Ok, I immediately jumped to StudioPress support center, as my theme was one among the StudioPress themes, and raised a support ticket. Meanwhile, I started checking the issue myself if something could be deciphered.
That’s when I found the issue staring at me in plain sight.
While pasting the code snippet that I copied – I simply forgot to close the PHP snippet with a closing curly bracket! (It happens, come on – though I feel stupid for missing that out).
But here, that’s not the problem – if someone faces this issue – the entire site breaks down and you will not even be able to login back to your WordPress dashboard to undo your mistake.
Check this post in WordPress forums: Edited functions.php, didn’t get desired result, restotored php, can’t login now
So what do you do then? That’s the whole purpose of this blog post. Hopefully, this will help you out.
How to restore your broken website using FTP
Before getting into the solution – let me also tell you that I did Google a solution before I found it myself – however I found that the WordPress community forum, somebody suggested to rename the Themes folder and install it again (as given in the link above) – I don’t know how great a suggestion that would be because all your customization, if any, will also be lost. But with my solution below (as long as you know what mistake you did in which core file), your site will be back up and running in no time – if you quickly get to undoing your error.
Here’s exactly what I did to restore my website:
- Ok. My site is broken.
- I also forgot my site’s FTP password! Great!
- Went to my hosting provider’s dashboard to check and change the FTP folder’s password.
- Used Filezilla software to login to my site’s FTP folder and successfully populated all my Theme’s folders and files.
- Opened up functions.php file – to be safe – I just deleted the entire code snippet that I inserted there.
- Saved and uploaded it back to the FTP folder.
- Refreshed the website.
- Started humming my favorite song as my website was back up and running!!
- Took a backup of my website and made arrangements for automatic and periodical backups.
Hopefully, you will find this guide useful. This definitely happens in every blogger’s life at least once – especially if you are a newbie blogger trying to tinker with the WordPress core files, don’t worry – you will learn a ton of things!
If at all you have any question from the above points, feel free to ask in the comments section below.