Skip to main content

Command Palette

Search for a command to run...

Enqueue parent theme on functions.php - CSS and jQuery

Updated
0 min readView as Markdown

Source: developer.wordpres.org

Paste the code below in the functions.php of your Child Theme. And within the root of your child theme, there must be two folders: style.css and custom.js.

Your functions.php must have the tag "<?php" in the first line of the file.

// Enqueue parent theme on functions.php - CSS and jQuery

add_action( 'wp_enqueue_scripts', 'correct_css_js' );

function correct_css_js() {
 wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 
 wp_register_script( 'custom-js', get_stylesheet_directory_uri() . '/custom.js', array( 'jquery' ), '1.0', true );
 wp_enqueue_script( 'custom-js' );
}
13 views