xxxxxxxxxx
function ti_custom_javascript() {
wp_enqueue_script( 'example-script', get_template_directory_uri() . '/js/examplescript.js');
}
add_action('wp_enqueue_scripts', 'ti_custom_javascript');
xxxxxxxxxx
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
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' );
xxxxxxxxxx
/**
* Proper way to enqueue scripts and styles
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
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' );
xxxxxxxxxx
<?php
//this the only line you need on WordPress to include jQuery in your plugin
wp_enqueue_script("jquery");
jQuery, WordPress, PHP
xxxxxxxxxx
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);
wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true);
xxxxxxxxxx
/**
* Enqueue scripts and styles.
*/
function ds2020_scripts() {
// $rand = rand(999, 999999999);
wp_enqueue_style( 'ds2020-style', get_stylesheet_uri(), '', '2.3' );
wp_enqueue_style( 'fontstyle','//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css', array(), '1.1', 'all');
//wp_enqueue_Style( 'ds2020-fontawesomeicons', get_template_directory_uri() . "/fontawesome-css/all.min.css" );
wp_enqueue_Style( 'ds2020-elegant_font', get_template_directory_uri() . "/elegant_font/style.css" );
wp_enqueue_script( 'ds2020-navigation', get_template_directory_uri() . '/js/navigation-v3.js', array(), '2020.06.06', true );
wp_enqueue_script( 'ds2020-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
wp_enqueue_Script( 'ds2020-main', get_template_directory_uri() . '/js/main-v3.js', array(), '2020.06.06', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ds2020_scripts' );
xxxxxxxxxx
function my_enqueue_stuff() {
if ( is_page( 'landing-page-template-one' ) ) {
/** Call landing-page-template-one enqueue */
} else {
/** Call regular enqueue */
}
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );