How do I set up a child-theme without using @import

The code that is in codex for queuing the style of the parent theme instead of using @import, is not well commented, so i will comment it more, so you have this: <?php function my_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), wp_get_theme()->get(‘Version’) ); } add_action(‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’); ?> 1.- line: $parent_style=”parent-style”; … Read more

How should I add JavaScript to a child theme?

You can do different things: Enqueue the new JS file via plugin Enqueue the new JS file via functions.php Add your JS code into functions.php through wp_header or wp_footer For adding new JS files to a wordpress site you should enqueue these files with wp_enqueue_style() and/or wp_enqueue_script(). This is the proper and safest way. I … Read more

Changes to functions.php not working

Closing PHP tag and then opening in the next line: Whenever there is something (even space, tab, newline etc.) after a closing PHP tag ?> or before an opening PHP tag <?php, PHP engine considers it as output. So the way your code is, it’ll generate some unnecessary output, that often throws error or warning … Read more

Overiding functions.php with child-theme

You can only override functions in a Parent Theme if the Parent Theme makes functions pluggable (by wrapping them in an if ( ! function_exists( ‘function_name’ ) ) conditional), or if the output of a function is passed through a filter (e.g. return apply_filters( $filter_name, $function_output ); Pluggable functions: in the Child Theme’s functions.php file, … Read more

CSS in child theme not getting loaded

Parent vs Child Themes get_template_directory_uri always refers to the parent theme you can verify this as you always should when things don’t load as expected by looking in the console in the browsers dev tools. These would show 404 errors for the CSS files, in the wrong folder. Instead, use get_stylesheet_directory_uri, the stylesheet family of … Read more