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

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

PREVIOUS NEXT
Code Example
Php :: php array unique array to string conversion 
Php :: BCMath PHP Extension 
Php :: laravel check collection not empty 
Php :: php trim all array elements 
Php :: storage image not showing in laravel 
Php :: php cors all 
Php :: a2dismod 
Php :: laravel route list 
Php :: show all terms of a custom taxonomy 
Php :: php filter only numbers 
Php :: php replace return character 
Php :: execute artisan command from route 
Php :: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) 
Php :: woocommerce cart button shortcode 
Php :: str slug laravel 
Php :: if ip is php 
Php :: php ucfirst all words 
Php :: wp get post content by id 
Php :: file delete in laravel 
Php :: var_dump _post php 
Php :: php cut off first x characters 
Php :: how validate hash string in laravel 
Php :: compare hashed password and a text password in laravel 
Php :: Error Call to undefined function CodeIgniterlocale_set_default() 
Php :: codeigniter 3 limit 
Php :: carbon add minutes 
Php :: common array methods php 
Php :: why use ob_start() in php 
Php :: wp max revisions 
Php :: main.WARNING: Session size of 315269 exceeded allowed session max size of 256000 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =