In this section we will learn enqueue scripts and style.
this is a good practice to write all css and js in your theme function.
this is a good practice to write all css and js in your theme function.
this code wirte inside functions.php file in your theme.
and one more thing you need to do call a hook before closing head tag
<?php wp_head();?>
<?php wp_head();?>
functions.php
/**
* Proper way to enqueue scripts and styles
*/
/**
* Proper way to enqueue scripts and styles
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() ); // enqueue css
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); // enqueue js
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' ); // wp_enqueue_scripts is a hook
No comments:
Post a Comment