functions.php breaking site when I add custom code
-
Hi,
I’m a confirmed web designer, write html and css very well, and copy and paste / edit js and php when needed. I regularly build custom WordPress sites, and use functions.php (very succesfully) to modify WordPress’s behavior.
I’m currently building a site with Twenty Twenty Three, I struggled to get my child-theme to function, using code snippets functioning on previous sites I’ve built, and numerous copy-pastes found online, eventually this one worked :
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { $parenthandle = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. $theme = wp_get_theme(); wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', array(), // if the parent theme code has a dependency, copy it to here $theme->parent()->get('Version') ); wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( $parenthandle ), $theme->get('Version') // this only works if you have Version in the style header ); }
I’ve kept this site ultra simple and could just about get away without using functions.php for modifying the layout, however it would be nice and also I don’t like not understanding whats going on ^^
So whenever I add a snippet after the child-theme snippet, the whole site crashes…
Is there a problem in this snippet ? Am I doing something wrong ?
Thanks !
The page I need help with: [log in to see the link]
- The topic ‘functions.php breaking site when I add custom code’ is closed to new replies.