Overiding functions.php with child-theme

I’ve been searching for a proper solution to override functions and hooks in my parent theme’s functions.php.
My parent theme has:

    define('TS_INC', TEMPLATEPATH .'/inc');
    require_once( TS_INC .'/file1.php');
    require_once( TS_INC .'/file2.php');

I want to have in my child theme an /inc folder with file2.php changed according to my needs.
This means that I want every call to file1.php to reach the parent theme /inc folder and calls to file2.php to go to my child/inc folder.

Read More

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. You can only override functions in a Parent Theme if the Parent Theme makes functions pluggable (by wrapping them in an if ( ! function_exists( 'function_name' ) ) conditional), or if the output of a function is passed through a filter (e.g. return apply_filters( $filter_name, $function_output );

    1. Pluggable functions: in the Child Theme’s functions.php file, simply define a function with the same name as the pluggable function you want to override. This is often the case with, for example, a Theme’s setup function, e.g. twentyeleven_setup().
    2. Filterable functions: in the Child Theme’s functions.php file, define a callback, and then call add_filter( $filter_name, $callback );

    If the Parent Theme doesn’t provide either of these two methods, then the Parent Theme’s functions cannot be overridden in a Child Theme.

    Edit

    Just for kicks and grins, since WordPress loads the Child Theme’s functions.php file immediately before the Parent Theme’s functions.php file, try adding the following to your Child Theme’s functions.php:

    <?php
    define( 'TS_INC', get_stylesheet_directory() .'/inc' );
    ?>
    

    It’s worth a shot, anyway.