2

Guided by the Codex doc on Child Themes I have created a twentythirteen-child theme for my website by copying the unchanged index.php file from the parent theme and by creating this simple style.css file:

/*
 Theme Name:   Twenty Thirteen Child
 Theme URI:    http://example.com/twenty-fourteen-child/
 Description:  Twenty Thirteen Child Theme
 Author:       Alexander Farber
 Author URI:   http://afarber.de
 Template:     twentythirteen
 Version:      1
 Tags:         light, responsive-layout, accessibility-ready
 Text Domain:  twenty-thirteen-child
*/

@import url("../twentythirteen/style.css");

.site-header .home-link {
        min-height: 800px;
}

However since my website uses a custom header image I've also edited 2 files in Wordpress -

1) I have changed the logo image height in the wp-content/themes/twentythirteen/inc/custom-header.php:

#'height'                 => 230,
 'height'                 => 800,

2) I have added #main anchor to the home-link in wp-content/themes/twentythirteen/header.php

<a class="home-link" href="<?php echo esc_url( home_url( '/#main' ) ); ?>"

I realize, that the core WordPress files shouldn't be edited, because the changes will be overwritten and lost after the next WordPress version update.

But I don't quite understand, how to put the 2 above changes in the functions.php suggested by the doc?

Could someone please give me some hints?

2

I would like to refer back to this answer on one of your previous questions about this subject. As said in that answer, you should never make changes to the twenty thirteen theme, and for that matter, to any theme/plugin you are not the author of, this includes core files as well.

But I don't quite understand, how to put the 2 above changes in the functions.php suggested by the doc?

OK, you have your child theme set up, now you need to create a file in your child theme's root and call it functions.php. Open this file and add an opening php tag (<?php) right at the top and press enter and save this file

For the first line of code, you can simply just change the custom-header arguments with this function

function my_custom_header_setup() {
    $args = array( 'height' => 800 );
    add_theme_support( 'custom-header', $args );
}
add_action( 'after_setup_theme', 'my_custom_header_setup' );

This will go into your child theme's functions.php starting on line 2

For the second part, simply copy the twenty thirteen's header.php file to your child theme's root, open it up, make your changes and save it. Your child theme will now use this header.php instead of twentythirteen's header.php. You can use this method for all other template files, except functions.php and functions.php related files, as you will trigger a fatal error. For example, if you need to make changes to index.php, simply copy it to your child theme, open it up, make your changes and save the file. Your child theme will then use this index.php, and not that of the parent

2

Child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme's directory, and that file will be used instead of the parent theme's header.php.

If any up-gradation done then child theme changes will not be revert back.

  • 1
    You will trigger a fatal error, cannot redeclare error on the custom header – Pieter Goosen Jul 8 '14 at 14:17
  • So you suggest not to use functions.php here, but instead copy the inc/custom-header.php and header.php to my twentythirteen-child directory? And then to remove the unchanged methods in those 2 files? – Alexander Farber Jul 8 '14 at 14:18
  • 1
    @AlexanderFarber you cannot copy custom-header.php to your child theme, you will trigger a fatal error – Pieter Goosen Jul 8 '14 at 14:21
  • @AlexanderFarber just copy the header.php file in your child theme and make changes in that file. – dipali Jul 8 '14 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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