Answer the question
In order to leave comments, you need to log in
How to include the jQuery library from WordPress?
Good afternoon
Now I'm building a template from Bootstrap for WordPress and I came across the fact that the menu during adaptation works if a remote file is connected from a folder inside the template or on another server as written below:
function jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false);
wp_enqueue_script('jquery');
}
if (!is_admin()) add_action('wp_enqueue_scripts', 'jquery_enqueue', 11);
Answer the question
In order to leave comments, you need to log in
You just don't need to re-register anything. Plus, it is usually enabled by default (but it depends on the theme).
function jquery_enqueue() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'jquery_enqueue', 10);
wp_enqueue_script ( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false )
$deps = array()write down the dependencies here
wp_enqueue_script('admin.bundle', plugins_url('/admin.bundle.js', __FILE__), array('jquery'), '1.12', true);
wp_localize_script('admin.bundle', 'Slug_API_Settings',
array(
'root' => esc_url_raw(rest_url()),
'nonce' => wp_create_nonce('wp_rest'),
'ajaxurl' => admin_url('admin-ajax.php'),
'myajaxnonce' => wp_create_nonce('myajax-nonce')
)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question