• Hi Everyone!

    I got one BIG question: I made a (parent-)theme and are now going to build a child theme upon it (for the/my first time). Due to the fact, that i like to re-use parts of my work, i tend to make custom functions like “get_nav_web_main();” (and other custom files) to get some php-file from somewhere out of my folders (for e.g.:) /lib/functions/functions-module.php … which then looks in the code like this:

    function get_nav_web_main() {
    		$nav_web_main = include(D2THEMELIBNAV . '/nav-web-main.php') ;
        	echo apply_filters('get_nav_web_main', $nav_web_main );
    	}

    Now my question is: How can i include other files in my childthemes, or how do i override those functions?

    I always made new themes out of my “base theme”, but i saw, that child-themes may be a much better (updateable) concept. I never made a child-theme before and the codex-documentation isn′t that much detailes, as i would need it in this case.

    I Hope someone can lend me a helping hand or brain ??

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m just beginning to develop for child themes, but from what I’ve experienced, any file you place in the child theme will override the parent theme.

    The exceptions are functions.php and style.css, where both parent and child (if present) theme files are included. The child theme files are loaded first.

    So, to override a function, you need to put it in the functions.php file. Important note : make sure you wrap functions in if(!function_exists… otherwise you’ll get a fatal error for redeclaring a function.

    While the functions.php in your child theme will augment rather than override the one in the parent theme (that’s where my phantom widgetised sidebar came from – doh!), style.css depends on how you include it. If you follow the pattern of the WordPress default theme and just use a link element in <head> then there isn’t any mechanism to refer to the parent’s style.css and you’ll need to add a line to load it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Parent & Child Theme – …include?’ is closed to new replies.