Ask any question about WordPress here... and get an instant response.
How can I enqueue custom styles and scripts in my WordPress theme?
Asked on Nov 27, 2025
Answer
To enqueue custom styles and scripts in your WordPress theme, you should use the `wp_enqueue_style` and `wp_enqueue_script` functions within the `functions.php` file of your theme. This ensures that your styles and scripts are properly loaded and managed by WordPress.
<!-- BEGIN COPY / PASTE -->
function my_theme_enqueue_styles() {
wp_enqueue_style('my-custom-style', get_template_directory_uri() . '/css/custom-style.css');
wp_enqueue_script('my-custom-script', get_template_directory_uri() . '/js/custom-script.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
<!-- END COPY / PASTE -->Additional Comment:
- Place the code in your theme's `functions.php` file.
- `get_template_directory_uri()` retrieves the theme's directory URL.
- The `array('jquery')` parameter sets jQuery as a dependency for the script.
- The `true` parameter in `wp_enqueue_script` loads the script in the footer.
Recommended Links:
