If you run a WordPress site, you’ve already come across articles and tutorials telling you to make changes to either a theme or a plugin file. Apart from that, you might need to make changes to your own CSS without relying upon the inbuilt methods of your theme via the customizer. WordPress has allowed us to make these changes from the admin dashboard for years, and it’s always been dangerous. Here’s where you can edit plugin files, for example:
You can edit both theme and plugin files this way.
The Dangers of the In-Built File Editor
The problem with editing files this way is that if something goes wrong, your site can crash – including the admin section. The last part is what’s worrying. If you were relying on the admin section working to edit files, then when your admin area is inaccessible, you can’t revert the changes to fix your site!
For this reason, you must never edit files or themes from within WordPress even though you can.
When you log into your admin screen the first time, WordPress now even includes a warning advising you against making changes from this area. You can dismiss the warnings, but always remember that it’s a risk.
WordPress has come a long way in making the file editor stable. In the past, if you made a change to your plugin file that broke your site, you would be met with the dreaded “White Screen of Death”, and then unless you could find a way to revert the changes without logging into WordPress, there was nothing you could do.
These days, WordPress tries to revert dangerous changes automatically. Now if you do something that breaks your site, WordPress informs you that your changes were not saved and your site can continue working. But even then, this doesn’t catch all mistakes. It’s entirely possible for you to screw up something so bad that it slips past WordPress checks and you lose access to your admin screen.
Knowing all this, the best safest way to edit your plugin and theme files in WordPress is to use a file manager.
Using the Dedicated cPanel File Manager
Luckily, there exists a way to edit these files, that doesn’t depend on logging into WordPress. All NameHero customers have access to the cPanel backend. Here’s the file manager section:
Using this, you can navigate to your site’s folder (usually after clicking through public_html), locate the file you want, and open it in a text editor like this:
While you can make the changes here, I suggest you always take a backup of the file first. I do this by copy/pasting the contents into a good editor like Notepad++. I like Notepad++ because it’s built for quickly editing code, comes with inbuilt line numbers, and even syntax highlights. You can align code indentations, and easily find and replace stuff. It’s an invaluable tool for me!
So before making any changes in the cPanel editor, I suggest you copy/paste the contents into Notepad++ first. Then make and save your changes. If your site breaks, no worries. Just revert the changes in the backend, and if even that doesn’t work, take the copy in Notepad++ and replace everything in the file so that it’s back to its original state.
Use this Technique Even for Small Changes
It’s been years since I used the WordPress editor for anything. I’m too cautious to make even small changes where I’m confident nothing will go wrong. It’s a good habit to cultivate because while it can seem tempting to quickly open the WordPress dashboard and make a small change, you could end up completely breaking your site!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply