Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp enqueue

/** 
 *   Enqueue your theme styles and scripts in functions.php
 *   use time() instead of a proper versioning to avoid caching when developing
 */
function my_theme_enqueue_scripts() {
    wp_enqueue_style( 'default-style', get_stylesheet_uri(), [], '1.0.0', 'all' ); //default styles.css
    wp_enqueue_style( 'main-style', get_stylesheet_directory_uri() . '/assets/css/main.min.css', [], time(), 'all' );
    wp_enqueue_script( 'main-script', get_stylesheet_directory_uri() . '/assets/js/main.min.js', [], time(), false );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_scripts' );
Comment

enqueue wordpress

function wpdocs_theme_name_scripts() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() ); /* enqueues style.css */
    /* if you want to enqueue other styles use: */
    /* wp_enqueue_style( 'style-name', get_template_directory_uri() . '/css/your-style-name.css' ); */
    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
Comment

wordpress enqueue jquery

add_action('wp_enqueue_scripts', 'my_register_script_method');

function my_register_script_method () {
    wp_register_script( 'jqueryexample', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js');
}
Comment

enqueue wordpress

function my_scripts_method() {
    wp_enqueue_script(
        'custom-script',
        get_stylesheet_directory_uri() . '/js/custom_script.js',
        array( 'jquery' )
    );
}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
Comment

wordpress enqueue js

add_action( 'wp_enqueue_scripts', 'my_plugin_assets' );
function my_plugin_assets() {
    wp_enqueue_style( 'custom-gallery', plugins_url( '/css/gallery.css' , __FILE__ ) );
    wp_enqueue_script( 'custom-gallery', plugins_url( '/js/gallery.js' , __FILE__ ) );
}
Comment

PREVIOUS NEXT
Code Example
Php :: date casting from datetime to d-m-Y laravel 
Php :: link acf 
Php :: open php.ini in ubuntu 
Php :: how to install bootstrap in laravel 
Php :: composer update without dependencies 
Php :: php replace space with dash 
Php :: get cart page url in woocommerce 
Php :: var_dump _post php 
Php :: ucwords in php 
Php :: twig concat string 
Php :: laravel storage check file exists 
Php :: how validate hash string in laravel 
Php :: how to check if a string contains a substring in php 
Php :: set nav link active on the basis of route laravel 8 
Php :: laravel blade errors all 
Php :: 500 server error laravel 
Php :: string to datetime php 
Php :: cascade in laravel migration 
Php :: start server in laravel 
Php :: how to open server in php 
Php :: how to decode jwt token in php 
Php :: php file_get_contents url 
Php :: get acf repeater field 
Php :: log laravel 
Php :: remove all html codes using php 
Php :: define home url wordpress config.php 
Php :: php is numeric 
Php :: php self 
Php :: php discord webhook 
Php :: laravel generate slug 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =