How to enqueue styles and script through word press theme function page
- by admin
- 0
You can include styles and scripts through functions, rather than include inside head section of header file.
In function.php file of active theme add script and styles as follows.
function fun_name() {
wp_enqueue_style( ‘style’, get_stylesheet_uri() );
wp_enqueue_style( ‘style2’, get_template_directory_uri() . ‘/assets/style2.css’ );
wp_enqueue_script( ‘aldehyde-custom-js’, get_template_directory_uri() . ‘/js/custom.js’ );
}
add_action( ‘wp_enqueue_scripts’, ‘fun_name’ );
You can include styles and scripts through functions, rather than include inside head section of header file. In function.php file of active theme add script and styles as follows. function fun_name() { wp_enqueue_style( ‘style’, get_stylesheet_uri() ); wp_enqueue_style( ‘style2’, get_template_directory_uri() . ‘/assets/style2.css’ ); wp_enqueue_script( ‘aldehyde-custom-js’, get_template_directory_uri() . ‘/js/custom.js’ ); } add_action( ‘wp_enqueue_scripts’, ‘fun_name’ );
You can include styles and scripts through functions, rather than include inside head section of header file. In function.php file of active theme add script and styles as follows. function fun_name() { wp_enqueue_style( ‘style’, get_stylesheet_uri() ); wp_enqueue_style( ‘style2’, get_template_directory_uri() . ‘/assets/style2.css’ ); wp_enqueue_script( ‘aldehyde-custom-js’, get_template_directory_uri() . ‘/js/custom.js’ ); } add_action( ‘wp_enqueue_scripts’, ‘fun_name’ );