Create a child theme which changes the footer

Description: Use the demo theme as parent. Create a child theme which has its own footer.php with the text Footer from the child theme. Activate the child and check the output.

Hint:

  • The child style.css needs a Template: line with the folder name of the parent.

Solution

/*
Theme Name: My Child Theme
Template: tc-theme
*/
<footer><p>Footer from the child theme</p></footer>
<?php wp_footer(); ?>
</body>
</html>
Terminal output

$ wp theme activate tc-child
Success: Switched to 'My Child Theme' theme.
$ wp eval 'echo get_template() . " is the parent, " . get_stylesheet() . " is the active theme";'
tc-theme is the parent, tc-child is the active theme
$ curl -s http://example.com/ | grep "<footer>"
<footer><p>Footer from the child theme</p></footer>

How it works

  • Template: tc-theme makes tc-theme the parent. WordPress loads every file from the child first, and from the parent when the file is missing in the child.
  • All other templates (header, index) still come from the parent.

Read WordPress Child Theme.


Learn more about the similar topics:
Tutorials
WordPress Themes
WordPress Top Theme List
WordPress Theme Files and Functions
WordPress Template Hierarchy
WordPress Enqueue Scripts and Styles
WordPress Loop
WordPress WP_Query Class
Exercises & Assignments
Build and activate a minimal classic theme
Show the three latest posts with WP_Query
Load a stylesheet with wp_enqueue_style and a version
Show a message only on the front page
Create a child theme which changes the footer
Interview Questions & Answers
What is a WordPress theme?
What are commonly used WordPress theme functions?
Which function is used to get the home URL in WordPress?
Which are the necessary files for a WordPress theme?
What is the use of the wp_head() function in WordPress?
What is the WordPress Loop?
What is the difference between is_home() and is_front_page()?