Quantcast
Channel: WordpressErrors
Viewing all articles
Browse latest Browse all 147

A Guide to Overriding Parent Theme Functions in Your Child Theme

$
0
0

If you’ve had any experience working with parent and child themes in WordPress, you’ll know that the template files in your child theme override those in your parent theme. So for example if your parent theme has a page.php file and you create a new one in your child theme, WordPress will use the one in the child theme when displaying pages.You might think that functions would work in the same way: create a new function in your child theme’s functions.php file with the same name as one in the parent theme, and it’ll take precedence. Unfortunately it isn’t as simple as this.In this tutorial I’ll show you three methods you can use to override functions from the parent theme in your child theme: pluggable functions function priority removing functions from the hook they’re attached to How Functions in Parent and Child Themes WorkBefore examining the methods for overriding functions in your child themes, it helps to understand how functions work in parent and child themes.Firstly, you need to know that all of the functions in your parent theme will be run when you’re using a child theme

See the article here:
A Guide to Overriding Parent Theme Functions in Your Child Theme


Viewing all articles
Browse latest Browse all 147

Trending Articles