Functions.php in child theme
-
Quick question about adding code to functions.php in my child theme. When I created my child theme instead of doing @import, I added functions.php in FTP and put the following code in there.
<?php
function theme_enqueue_styles() {$parent_style = ‘parent-style’;
wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array( $parent_style )
);
}
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );Which from my understanding is the same thing as @import but is the better option now for speed of my website.
Now, I have tried adding new code below this in that functions.php in my child theme and it makes my site go blank. I understand functions.php is the one place where you can’t modify the same file that is in the parent. I’ve looked all over and haven’t found a clear answer. So Should I create a new functions.php file and name it something different on top of the original functions.php. So I would have TWO functions.php files, but one could be called for example functions-child.php. And then I would be able to add functions to it??? And would that be completely different from just adding code to the original functions.php. Because in the end I just want to modify the functions of the website, but I’m wondering if that second file would interfere with the first????
Thank You for any explanations
The topic ‘Functions.php in child theme’ is closed to new replies.