Best way to modify WordPress theme

Do not modify the template files directly. If you update or upgrade the selected theme, all your changes will disappear.

Use child theme instead.

Step 1: Create a child theme folder

  1. Create a folder for the child theme in folder wp-content\themes\
  2. Name the child theme folder with suffix -child
  3. For example, if parent theme folder is twentysixteen, the child theme folder should be twentysixteen-child

Step 2: Create a style.css file

  1. Within the child theme folder, create style.css
  2. Copy the style sheet header below, customize it, and add it to the top of style.css

    Tip: The “Template” field must match the folder name of the parent theme

    Tip: The mandatory fields are “Theme Name” and “Template”, the rest is optional

  3. Add style rules below the header

Step 3: Create a functions.php file

  1. Within the child theme folder, create functions.php
  2. Copy the code below

Step 4: Activate the child theme

  1. Under Appearance > Themes, the new child theme should show up now

    Tip: Add screenshot.png in the child theme folder to display a thumbnail for the child theme

  2. Click “Activate” to start using the child theme

Modify other files such as header and footer

All files within the theme folder can be modified. Examples:

Header section: header.php

Footer section: footer.php

Single post content section: template-parts/content-single.php

Make a copy from the parent theme folder and save it into the child theme folder. If a file does not exist, the parent file will be used.

Share: