P
P
plmax2016-03-05 08:49:18
WordPress
plmax, 2016-03-05 08:49:18

How to organize a function override in a child theme?

In the parent theme, the function is connected through the file at the end of functions.php.
In a child theme, I'm trying to override this function via

if (!function_exists('this_function')) {
    function this_function() {
        //  Ваш код.
    }
}

Due to connection rules I get:
Fatal error: Cannot redeclare this_function() (previously declared in ...\child-theme\functions.php:8) in ...\parent-themes\...\extras.php on line 163
Tell me how to change it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mr Crabbz, 2016-03-05
@Punkie

The parent theme should have:

if (!function_exists('this_function')) {
    function this_function() {
        //  Ваш код.
    }
}

In the child - already without function_exists:
function this_function() {
   //  Ваш код.
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question