We are sometimes asked about the best way to find which files to edit in a WordPress theme.
WordPress themes consist of several different files. Sometimes it could be hard for beginners to determine which files they need to edit to make sure changes of their theme.
In this text, we’ll show a simple and quick strategy to determine which files to edit in your WordPress theme.
Understanding WordPress Theme Template Files
All the highest WordPress themes follow the official best practices. This implies they use the usual file and template structure to prepare all of the code.
As an example, all WordPress themes have archive.php, single.php, functions.php, and other files.
Each of those files is used as a template to display a specific area of your WordPress website. For instance, single.php is used to display single posts and page.php template is used to display a single page.
Understanding the WordPress template hierarchy gives you a greater understanding of how WordPress works.
In the event you ever must add code to your WordPress theme, then it also helps you determine which files you could must edit.
For more details, see our complete cheat sheet for the WordPress template hierarchy for beginners.
That being said, let’s take a take a look at the best way to easily find which files to edit in WordPress theme.
Finding Template Files to Edit in WordPress Theme
Very first thing you want to do is install and activate the What The File plugin. For more details, see our step-by-step guide on the best way to install a WordPress plugin.
The plugin works out of the box, and there are not any settings so that you can configure.
Upon activation, you want to visit the front end your website and you may notice a latest ‘What The File’ menu in WordPress admin bar.
Now you want to just take your mouse over to the menu item, and it’s going to display a drop-down menu listing the template files used to display this page.
Clicking on the file name will take you to the default WordPress file editor where you’ll be able to edit that individual file.
Nonetheless, we don’t recommend using WordPress file editor to edit theme files because there isn’t any undo option.
In the event you unintentionally lock yourself out of your website, then you definately would must use an FTP client to repair it. That’s why we recommend using a FTP client or the File Manager app in your WordPress hosting control panel.
You may edit theme files using any plain text editor like Notepad.
Making direct changes to your WordPress theme can be a nasty idea. Those changes will disappear while you update your theme.
In the event you are only adding some CSS, then you definately can add it as custom CSS in WordPress. For all other changes to your theme files, you must create a toddler theme.
The ‘What The File plugin’ can enable you locate the theme files that you want to copy and edit in your child theme.
Note: The menu item added by the plugin within the admin bar might be visible to all logged-in users, and it has a link to an external site. It’s best to only use this plugin within the development environment comparable to a staging site.
We hope this text helped you discover which files to edit in your WordPress theme.
It’s possible you’ll also wish to see our WordPress theme development cheat sheet or take a take a look at WordPress generated CSS classes which you could use to style your themes.