In this article, we will learn how to enqueue style and script in WordPress.
We will start by enqueue using two functions wp_enqueue_style() and wp_enqueue_script(). Both the two functions have the first 4 parameters that are the same and the last one is different.
syntax:
wp_enqueue_style( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, string $media = 'all' ) wp_enqueue_script( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, bool $in_footer = false )
Explanation:
Here is an example code:
<?php function thecodehubs_enqueue_script_style() { wp_enqueue_style( 'stylesheet', get_stylesheet_directory_uri() . '/style.css', array(), '1.0.0', 'all'); wp_enqueue_script( 'custom_js', get_stylesheet_directory_uri() . '/js/custom.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'thecodehubs_enqueue_script_style' ); ?>
Output:
style.css
custom.js
if you want to enqueue style and script for administration panel then use add_action( ‘admin_enqueue_scripts’, ‘thecodehubs_enqueue_script_style’ );
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular