If you want to make changes to the page and post templates in your WordPress theme, you need to to make the changes in child page templates.
You never want to edit the parent theme page templates, otherwise every time your theme is updated, your changes disappear and you have to edit the files all over again.
What you need
To create the templates, you need to use either an FTP program like Filezilla, or the file manager tool in your web hosting account. You cannot create child page templates from within WordPress.
If you have more than one theme installed, you also need to know the name of the active theme. If you don’t know, in your WordPress dashboard, go to Appearance > Themes. The active theme is the first one listed.
Creating the child page and post templates
The cPanel dashboard is used for this tutorial. If you don’t have cPanel installed on your hosting account, use whatever file manager tool your webhost offers and follow along. The concepts are the same.
Step 1: Creating a new folder
If you do not have a child-theme installed, you need to create a folder to store the template files.
To create a new folder, follow these steps:
- Login to cPanel then click File Manager. Select the directory where WordPress is installed then click Go.
- Double-click the folders wp-content > themes. Once you are in the themes folder, you need to create a folder for your child templates.
- Click New Folder to create a folder for your child templates.
- Name the folder. Give it an easily recognizable name. It is best to name it as a child of a specific theme. For instance, themename_child.
- Click Create New Folder.
Step 2: Copying page template files to the child folder
The most common files that need to be copied for editing are the following:
- index.php – the template for your blog post list page.
- page.php – the template for pages.
- single.php – the template for posts.
- functions.php – this is the theme functions file. Don’t edit it unless you know what you’re doing or you might break your theme.
Only copy the file(s) you need to edit. There is no benefit to having an unused child template in the folder.
Copy the files from the parent folder to the new child folder by following these steps:
- Double-click to open the folder of the theme you are using.
- Highlight the file you want to copy, right-click, then click Copy.
- Press Ctrl and drag the file to the child folder from the list on the left. (You may have to expand the folders to find it: public_html > wp-content > themes.) You can also type the path in the window then click Copy File(s).
- Repeat to copy other files, if needed.
Now the child template files are accessible through your WordPress dashboard where you can edit them.
Editing child templates
To edit one of the child template files, in your dashboard, go to Appearance > Editor. In the drop-down list, select your child theme then click Select. Click the name of the file you want to edit from the list on the right.
Leave a Reply