How to Create WordPress Child Page Templates

You are here:
Estimated reading time: 2 min

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.

This is not the same as creating a full-fledged child theme. Use these instructions if you need to alter some of the page template files that are located in the parent theme but you either don’t have a child theme or the child theme doesn’t contain the templates you need to edit. For instructions on creating a new child-theme, read this blog post.

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.

Before working on template files, create a full backup of your WordPress site.

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.

You cannot have a child of a child theme. If you already have a child theme installed, skip this step.

To create a new folder, follow these steps:

  1. Login to cPanel then click File Manager. Select the directory where WordPress is installed then click Go.

    File manager directory selection window

    Select the directory where WordPress is installed

  2. Double-click the folders wp-content > themes. Once you are in the themes folder, you need to create a folder for your child templates.
  3. Click New Folder to create a folder for your child templates.

    Add New Folder icon in cPanel

    Click New Folder in the toolbar

  4. 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.

    Name New Folder window in cPanel

    Give the new folder a descriptive name

  5. 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:

  1. Double-click to open the folder of the theme you are using.
  2. Highlight the file you want to copy, right-click, then click Copy.
  3. 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).

    Copy file window in cPanel

    Ctrl+drag the file to copy it or type the path

  4. 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.

After editing the template, click Update.
Tags:

Reader Interactions

Leave a Reply

March 17-18 only! 2 for 1 St. Patrick's Day Sale! Get Backup Buddy + iThemes Security Pro for price of 1 subscription for 4 years.Get the Deal!