How to Override WordPress Parent Theme Functions

Spread the love
  • 3

A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.

No doubt that using a child theme makes it super easy for you to edit the styles and the functions of the main (parent) theme.

Creating a child theme is a very simple process. But overriding the parent theme functions can be tricky. So, let me explain how to override WordPress parent theme functions without having any problems or fatal errors such as ‘PHP Fatal error: Cannot redeclare function‘.

Override WordPress Parent Theme Functions – The Right Way

When you want to override one of the parent theme template files, all you need is to copy the template file from the parent theme, paste it to your child theme folder and start editing it.

Example: If you want to override your parent theme page.php file, copy it from the parent theme folder and paste it in the child theme folder.

This is not the case with the functions from functions.php file or the other functions that exist in the different theme folders such as /includes/, /framework/, etc. To override a function, it has to be wrapped in an IF statement of function_exists.

Example: To override a function from your parent theme, typically you would copy the function and paste it in your child theme functions.php
But the function from the parent theme must be wrapped in an IF statement like the following:
if ( ! function_exists( 'parent_theme_function' ) ) :

function parent_theme_function() {


Then, you can copy the function to your child theme’s functions.php file as following:

function parent_theme_function() {


This means that you only can override the functions that are wrapped in a function_exists IF statement.

(Visited 501 times, 1 visits today)
  • 3


I write about Multilingual WordPress, SEO, Website Performance. Also, I like answering WordPress question on Quora. When I have the time, I run online sessions to teach WordPress for my personal FB page fans!

libero risus lectus Praesent eleifend in felis

Pin It on Pinterest

Do you find this interesting?

Share it with your friends!