Recently, one of our readers asked how do you find which files to edit in their WordPress theme? If you are new to WordPress theme development and want to customize your theme, then you need to learn which template files in your theme you need to edit. In this article, we will show you how to easily find which files to edit in WordPress theme.
Template Files in WordPress Themes
WordPress themes control how your website looks to your users. Each theme contains several template files which control the appearance of a particular section or page in your WordPress theme.
single.php file controls the appearance of single posts on your website. It is not the only file to do that.
If your theme does not have a single.php file, then WordPress will look for alternate templates like index.php to display the page.
Most beginners are not familiar with template hierarchy in WordPress. This makes it harder for them to figure out which files to edit when they want to customize their themes.
Having said that, let’s see how to easily find out which files to edit in your WordPress theme.
Finding Template Files in WordPress Themes
First thing you need to do is install and activate the What The File plugin. For more details, see our step by step guide on how to install a WordPress plugin.
The plugin works out of the box, and there are no settings for you to configure.
Upon activation, you need to visit your website and you will notice a new ‘What the file’ menu in WordPress admin bar.
Now you need to just take your mouse over to the menu item, and it will 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 can edit that particular file.
However, we do not recommend using WordPress file editor to edit theme files because there is no undo option. If you accidentally lock yourself out of your website, then you would have to use a FTP client. That’s why we always using a FTP client and plain text editor to edit your files.
Making direct changes to your WordPress theme is also a bad idea. Those changes will disappear when you update your theme.
If you are just adding some CSS, then you can add it as custom CSS in WordPress. For all other changes you should create a child theme.
‘What The File plugin’ can help you locate the theme files that you need to copy and edit in your child theme.
Note: The menu item added by the plugin in the admin bar will be visible to all logged in users, and it has a link to an external site. You should only use this plugin in development environment.
We hope this article helped you learn how to find which files to edit in WordPress themes. You may also want to see our guide on how to test your WordPress theme against latest standards
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.