While making modifications to WordPress, we need to edit the theme files located inside the /wp-content/themes/ folder. Sometimes, we might have to manually add some lines of code to header.php or other files like footer.php or content.php. The purpose of the edit could be to add simple lines of code like adding a favicon link rel code to header.php or Google Analytics code to footer.php.

The most common way of editing website files is via FTP or by using a File Manager/File Editor provided by the web host. But there exists a simple way of doing this. You can simply do it from the admin dashboard using the Appearance > Editor feature. From there, you can access all the PHP files of a theme and the main style sheet that is the style.css file.

Also Read: How to create child themes and preserve the changes made to the theme files even after upgrading.

So, what you have to do is simply login to WordPress administration dashboard and access the editor from the menu: Appearance > Editor.

WordPress Appearance Editor

It will open the style.css file by default for the currently active theme. All the PHP files of the active theme are listed right under templates. Click on any file and the editor will open it so that you can make modifications. Under the dropdown, “Select theme to edit:”, you will find all the other themes that are installed. Pick one and click on Select if you want to modify the files of the theme which isn’t active.

There is also a Documentation feature present right under the text content that is being edited. There you will find the resources to WordPress functions and hooks that are used in the currently open file. Choose a function and hit Look Up to open the official documentation page and get all the details.

After making the necessary edits, hit the update file and WordPress will make the changes to the theme file permanently.

Please note that since the editor isn’t a powerful text editor, you won’t find features like syntax highlighting, auto-completion of code etc. This editor at its current stage is recommended only to make minor and quick changes. Before making the changes, it is crucial to back-up the current file by simply copying and pasting it somewhere or by backing up the entire WordPress installation.

Leave a Reply

Your email address will not be published. Required fields are marked *