Although it seems like you should be able to just call the function and have it load the script, it’s slightly more complicated. Instead, scripts need to be registered and enqueued inside a hook, so they’re loaded in the right order.
To get jQuery loaded on the front end of your theme wrap the function call inside a callback for the wp_enqueue_scripts
action. One way is to add this to your theme’s functions.php
file:
add_action( 'wp_enqueue_scripts', function () { wp_enqueue_script( 'jquery' ); } );
See https://developer.wordpress.org/reference/functions/wp_enqueue_script/#notes for more info.
Related Posts:
- My javascript is returning this error: $.ajax is not a function
- Bootstrap – Uncaught TypeError: Cannot read property ‘fn’ of undefined
- jQuery: How can I create a simple overlay?
- Invalid or unexpected token on a very simple function
- How to make Bootstrap carousel slider use mobile left/right swipe
- javascript function wait until another function to finish
- How to get a cross-origin resource sharing (CORS) post request working
- Adding a page loader using jQuery
- jquery – return value using ajax result on success
- onclick event pass
- id or value
- How can I change CSS display none or block property using jQuery?
- Can you detect “dragging” in jQuery?
- Twitter Bootstrap Modal Form Submit
- ajax stopped working when not logged in?
- How to overwrite a JavaScript core function?
- Automatically decrease font size for long words
- Custom function to rearrange attachments when creating posts – Almost there
- jQuery and AJAX Not working with Select Form Element
- Horizontal scroller with post_thumbnail’s
- Force wp_enqueue_scripts to the HEADER?
- WordPress and jQuery [closed]
- Any good lightbox-like option that works in WP 3.2.1?
- $wp_customize customizer_preview_init not firing inside javascript
- Disable collapse of admin meta boxes
- jQuery code not firing on page despite registering and enqueuing scripts
- Ajax pagination works only first and third time
- How to properly add Bootstrap and JQuery Javascripts?
- how can I make $ work in wordpress for jQuery?
- WordPress Jquery Fade in, Fade out effect
- How to use Bootstrap with WP’s jQuery? [closed]
- Is there a restriction in WP on the use of jQuery load function?
- Gutenberg Filtering Metaboxes by Post Format
- WordPress site in China times out on requests to youtube [closed]
- No data received
- show element on page load from external url only [closed]
- CodeMirror on Custom Widget Textarea
- Sending click events to Google Analytics in WordPress: the easy way
- Accordion scrolls page too low after clicking on the title [closed]
- Exclude some scripts from removing unique scripts from head function
- Passing jQuery into the WordPress media uploader
- jQuery undefined function error with WP jQuery, but works with Google CDN
- How to enqueue jquery in admin and why is it not already there?
- Adding JS to one page
- Simple text and image slider
- Display posts from another site using REST API in an asynchronous manner
- Why does my jQuery AJAX return 0?
- jQuery script is not working inside ‘head’ tag
- Why doesn’t jQuery use $, and how can I get it do so (GLOBALLY)?
- How do I include javascript/jquery image resizing with wordpress?
- Title on hovering on the featured image
- Loading a newer version of jQuery within WordPress
- WordPress 3.1 makes my drop down menu dissapear, jquery dont work
- Having trouble setting / modifying cookies
- Loading dynamic content with AJAX breaking jQuery
- Adding JavaScript file in Admin Panel
- How do I use jQuery to add the TinyMCE WYSIWYG editor to a textarea?
- why is my wordpress Jquery-Ajax call not working?
- How to retrieve WP_Object that is inside an array of another array
- jQuery – Toggle megamenu submenu items by click
- General Settings: display custom plugin field after Site Address field
- WP Customizer: Save a control state
- WordPress Insert not working with ajax
- WP AJAX API with JS file
- need to override function in jquery.ui.datepicker.js
- Is there some jQuery conflict here?
- Dynamic WordPress editor in meta box
- Getting jQuery AJAX to work in WordPress (getting -1)
- How to modify iFrame content in an admin thickbox
- How to wrap posts into divs?
- jQuery Drill Down iPod Menu FOUC and Selecting Current page
- Absolute path to stylesheet_dir/images/my_img.jpg does not work?
- jquery.min has very long TTFB
- animate.style on wp-login.php
- Storing current page WP list table HTML data into a PHP variable
- Form validation before submitting
- bundled jquery in theme js not working with wp_localize_script
- Special Characters and Spaces are not transferred correctly via AJAX call.
- How to manipulate elements on the Insert Media Attachment settings popup
- How to toggle custom WP archive list
- I can’t enqueue Suggest.js in frontend – not added
- Jquery code won’t run loaded from WP, but run from console
- WordPress and Raty.js
- JQuery is not defined but jquery script is loaded in source [closed]
- owl carousel not working after ajax load [duplicate]
- jQuery post method in admin menu
- jquery not working correctly in plugin options page?
- jQuery AJAX add json2 dependency?
- Running javascript in a child theme. Works in jsfiddle
- How to block action if post is “dirty”?
- $ not defined using jQuery in WordPress
- How to read the contents of single post through RSS feed
- jQuery Ajax / Modal admin event not firing since 3.6. Seems to not recognize “a” tag
- Auto Select Child categories on Multiple Dropdown – Jquery
- WordPress video end function [duplicate]
- jQuery Live Form Validation in WordPress
- bootstrap-slider.js by seiyria not working in wordpress
- Sliders with buttons [closed]
- Fire an event after Featured Image selection
- Elementor form – checkboxes validation
- How to add input file plain text and submit to publish?