Sooner or later, you’ll likely feel the need to make changes in your WordPress theme. The best thing is that you can edit your theme directly from the admin panel. Essentially, WordPress comes with a built-in editor, called as the “Theme Editor” that help edit files from your browser online.
However, you can even make changes to your theme by editing your WordPress core files stored on your computer. And, once you’ve made the required changes to the website template, you just need to upload them to your website using an FTP client. A simple piece of advice: avoid editing the core files of your WordPress install since you can’t undo the changes made and written into the files (except for the case when you have stored a back up of all your files somewhere).
Through this post, I will help you understand the process of editing your website theme as well as PHP files from your WordPress install admin menu.
Note: I will be using WordPress and WP interchangeably throughout the post.
But Before Proceeding
Let us look at a few easy-to-follow and important tips you must take into consideration when making any edits to your WordPress files:
• Create a BackUp: Make sure to create a backup of your WordPress website files on a regular basis or even, if you are moving to convert website to WordPress theme. Remember to keep those files in a safe place. Doing so, will help you restore your lost data – that you might have accidentally deleted or removed. Especially, you should create a backup when editing your WP core files.
• Get Familiar with File Permissions: One of the most important thing you should remember before getting started with the process of modifying WP core files is to gain basic knowledge of how you can set the appropriate file permissions. There is a greater likelihood that you can’t edit a file unless the file is writable. And so, you’ll be required to make changes to the file permissions prior to making any changes to your theme files.
• Edit WordPress Files using a Theme Editor Tool: Perhaps, you might use a Word Processor for editing your WP files. However, using a Word Processing Program usually change quote marks into characters or add unnecessary (junk) code; this can result in causing the file to break. A viable alternative is to make use of Plugin and Theme Editors for making edits to a file.
Understanding the Process of Editing WP Theme and Files
The best way to edit a WordPress theme and any PHP file(s) is to make use of the Theme Editor and Plugin Editor. Both “Theme” and “Plugin” Editors are two of the built-in WordPress editors that allows to edit the theme files directly from your browser using the admin menu.
Let’s assume you would like to make edits in the WordPress default TwentyFourteen theme. In that case, first you’ll need to log into your WordPress site admin panel. Once you’ve accessed your admin panel, you will see a navigation menu on the left side of your admin dashboard screen. From there, go to Appearance → Themes and click on the Editor option. This will open the Themes Editor Screen (as you can see in the image below). Likewise, you can also access the Plugins Editor Screen, by clicking on Appearance → Plugins → Editor.
You can see all the theme files located on the right-hand side of the Theme Editor Screen. Simply open the file that you would like to edit in the editor screen.
Note: Keep in mind that making updates to your theme directly will overwrite the changes you have made to your theme. And so, to save your changes from getting lost, you should consider creating a “Child Theme” – that can be used for keeping all your changes.
Which Files You Can Edit from within the Administration Menu?
Below are the files that can be edited from within the WordPress built-in editor (but only if they are writable):
• HTML Files
• PHP Files like index.php, header.php, sidebar.php, etc.
• CSS File (i.e. style.css)
• and TXT (and related text-like files such as RTF)
While you can edit all the above-listed files using the Plugin Editor, but with Theme Editor, you can only edit PHP and CSS files.
A Few Key Considerations: on Editing Theme Files Using WordPress Editors
Before you start making edit to your website theme files using the WP built-in editors (i.e. Theme Editor or Plugin Editor) make sure to consider the following things:
1. Make Instant Changes to Theme Files in Offline Mode
Using the WordPress built-in editors, you can make instant changes to your website theme in real-time. However, it is safer to make the edit to your file copies in the offline mode, and upload the changes to the theme once you’re satisfied. This will save you from making errors while editing your theme in a hurry. Also, make sure to create a backup of your current file before editing.
2. Get Familiar with Editor Features
The WordPress Plugin and Theme editors are simple and provides easy access to view and edit your plugin and theme files, respectively. However, using these built-in editors you cannot perform advanced editing functions like syntax highlighting, code completion, etc. This is why it would be better to learn about your Editor features in advance.
3. Learn About File Permissions
In case you need to edit any theme file using the WordPress built-in editors (i.e. Plugin or Theme Editors), make sure to set the file permissions to “666”. To change the file permission mode, you will require to use an FTP client program or the file manager provided by your web hosting provider, and so on.
4. How to Combat Accidents and Hacking Attacks?
Lastly, you should be prepared to deal with worst case scenarios, such as loss of data or getting your website hacked. You can protect your data or theme changes from getting deleted or removed using your backup Files. This will make your site recover to its original form regardless of a site crash, inability to access your WP dashboard or any other situation.
And to cope up with hacker attacks and other accidents, it is recommended that you must disable users ability to edit any files from within the WordPress theme using the following line of code:
Note: Make sure to add this function in your theme’s wp-config.php file.
Hope that this post will help you learn the basics of editing your WordPress theme files from the admin menu.