Ask any question about WordPress here... and get an instant response.
How can I enqueue scripts properly in a child theme?
Asked on Nov 22, 2025
Answer
To properly enqueue scripts in a WordPress child theme, you should use the `wp_enqueue_scripts` action hook. This ensures that your scripts are loaded correctly and in the right order. Here's a simple example of how to do this in your child theme's `functions.php` file.
<!-- BEGIN COPY / PASTE -->
function my_child_theme_scripts() {
// Enqueue parent theme's stylesheet
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
// Enqueue child theme's additional script
wp_enqueue_script('child-custom-script', get_stylesheet_directory_uri() . '/js/custom-script.js', array('jquery'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'my_child_theme_scripts');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure your child theme's `functions.php` file is properly set up to include this code.
- Replace `'child-custom-script'` and file paths with your actual script handle and path.
- The `array('jquery')` parameter specifies dependencies; adjust as needed.
- Set the last parameter to `true` to load the script in the footer.
Recommended Links:
