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.cssneeds aTemplate: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-thememakestc-themethe 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 |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |