0

My theme uses the following in functions.php

require_once get_template_directory() . '/includes/admin-options.php';

I want to override this with my own version of the admin-options.php file, which I have stored in my Child Theme directory.

As per Codex instructions on Referencing / Including Files in Your Child Theme I've tried adding the following line in my Child Theme functions.php file

require_once( get_stylesheet_directory() . '/admin-options.php' );

both with and without commenting out the require_once line in the theme functions.php file.

Neither way works - the site won't load at all.

Echoing the line in my Child Theme functions.php gives the correct path for the admin-options.php file I want to include:

echo ( get_stylesheet_directory() . '/admin-options.php');

returns wp-content/themes/onetone-child/admin-options.php

What am I missing?

1 Answer 1

0

I think that in wordpress you can't override a file of functions of a parent theme, the only thing that can do is to make an override of the functions of this file in your functions.php of your child theme.

if ( ! function_exists ( 'my_function' ) ) {
    function my_function() {
        // Contents of your function here.
    }
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.