• I am using the WordPress default theme “Twenty-fourteen”. The header of this theme is way too narrow and sits to the left, so there is a large empty vertical space at the right (why they made it this way in this day and age I have no idea).

    The template I needed to customize is “custom-header.php” which is located in the parent theme subdirectory “inc”. The path is “../wp-content/themes/twentyfourteen/inc/custom-header.php”

    I created the child folder and required files (style.css, functions.php) as described in the WordPress Codex page on child themes. The functions.php file contains the following,

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    ?>

    I searched for the method to create a copy of the template “custom-header.php” and got so many different methods, all of which failed to work.

    I placed a parent copy of “custom-header.php” (with the modifications I made) into the root folder of the child theme, I also tried placing it in duplicate folder structure as the parent (/theme/twentyfourteen/inc) into the child theme (/theme/twentyfourteen-child/inc), both methods failed. The modified template did not work.

    I tried to add the following code to the functions.php, along with the above file placement,

    require_once( get_stylesheet_directory() . '/inc/custom-header.php' );

    but that only created the following error,

    Your PHP code changes were rolled back due to an error on line 11 of file wp-content/themes/twentyfourteen-child/functions.php. Please fix and try saving again.

    require_once(): Failed opening required ‘wp-content/themes/twentyfourteen-child/inc/custom-header.php’ (include_path=’.:/usr/php/56/usr/lib64:/usr/php/56/usr/share/pear’

    All the places I have been via Google resulted in the same information, which has failed to work.

    Can someone, hopefully a WordPress developer, explain how I can do this, to include a modified copy of the “custom-header.php” file in the child theme folder and make it work?

    Note: Maybe the functions in the function.php are insufficent or incorrect?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mwarbinek

    (@mwarbinek)

    Today, I used a plugin “Child Theme Configurator” to create a child theme, hoping that this would tell me how to configure this theme for a child theme setup.

    This plugin analysed my child theme setup and provided the same information I gave above, which actually confirmed that this theme “Twenty-fourteen” is either badly coded or there is something specific to this theme that requires a specific setup in the child theme folders.

    The plugin provide these 2 warnings it got when it analyzed the child theme setup,

    Warning: include_once(/home2/formwebd/public_html/test-wordpress/wp-content/themes/twentyfourteen-child/twentyfourteen-child/inc/custom-header.php): failed to open stream: No such file or directory in /home2/formwebd/public_html/test-wordpress/wp-content/themes/twentyfourteen-child/functions.php on line 19

    Warning: include_once(): Failed opening '/home2/formwebd/public_html/test-wordpress/wp-content/themes/twentyfourteen-child/twentyfourteen-child/inc/custom-header.php' for inclusion (include_path='.:/usr/php/56/usr/lib64:/usr/php/56/usr/share/pear') in /home2/formwebd/public_html/test-wordpress/wp-content/themes/twentyfourteen-child/functions.php on line 19

    So who is the theme author and where can I contact him/her/them about this theme?

    • This reply was modified 7 years, 1 month ago by mwarbinek.
    • This reply was modified 7 years, 1 month ago by mwarbinek.
    Thread Starter mwarbinek

    (@mwarbinek)

    Is there someone from WordPress team that can provide some help here, or is this just ignored?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Child Theme – Modify parent theme template file located in subfolder’ is closed to new replies.