As @Milo said , WP loads jQuery in no conflict mode so shortcut $ is not available for jQuery to use .You should not use the $ variable for jQuery within WordPress.As you said you are not into jQuery i’m just giving the code below..Try it.
jQuery(function ($) {
$(window).load(function() {
$('#main-slider').flexslider({
animation: "slide",
useCSS: false,
pauseOnHover: true
});
});
})
When you put script in the footer.php , you loaded jQuery from cdn .so $ is available and that’s why it worked.
Update:
What i mean is when you used
<script src="http://code.jquery.com/jquery.js"></script>
your source for jQuery.js is different that WP.
When you use
// Load JQuery:
wp_enqueue_script('jquery');
jQuery is loaded from WP bundle.
Related Posts:
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters
- Display random categories on the front page (Finding and Editing Theme Functions)
- Apply jquery script to only woocommerce product pages and categories
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Check javascript file Proper way in functions.php
- Enqueuing Script in functions.php vs on the page
- Add external js file to footer with id
- jquery won’t load in footer
- How to correctly add JQuery in a WP theme?
- Replace menu links with # and add name to its li
- Loading CDN that requires jQuery in WordPress
- How to load jQuery in the footer – nothing works for me
- Scripts not appending to element in AJAX call – why?
- How to search using ajax for exact phrase or words in an input field?
- how to en-queue jQuery to load before the tag
- Jquery implementation not working on page reload
- I can’t enqueue my scripts – They literally aren’t being added to my site
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Run a jquery script on on a certain template page
- Getting the teaser text without overriding global variables
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- How to load jQuery in TOP of wp_footer?
- “options.php” not found
- Include Jquery libraries in wordpress theme?
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Creating multiple category drop down
- How to setup a popup registeration page in wordpress with function.php
- wp_set_object_term via js btn frontend
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Multiple Notifications SetInterval
- Automatic add space if user enters number(any digit)
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- How do I get my nav menu to show sub pages?
- Add custom css to theme
- Javascript as Jquery Function Call?
- How to get postId from the argument $block when register_block_type()?
- Animated Accordion [closed]
- iOS and ajaxComplete
- WordPress can’t get jquery/unslider to work
- Is this an acceptable practice for WordPress theme development?
- Add loggedout class on body using a function or JS
- Are innerHTML elements visible to jQuery functions?
- What is the correct way to include my new functions and scripts in WordPress?
- How to override this theme function in child theme
- wp_nav_menu work in functions.php but not in the theme
- get_template_directory() – references parent theme directory
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- contact form in template with jquery,validate and ajax
- Linking Javascript in functions.php file
- Load CSS files in header of Bones theme?
- Dequeue scripts in IE7 only using functions.php
- How do I preserve changes to a theme’s functions.php across updates?
- get content from page through AJAX
- How can I assign separate stylesheets to different pages?
- How to make sure relative URL works when site is not on root domain?
- Can’t change theme name
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- colorbox not loading in
- Call javascript functions from each page
- Custom attributes to javascript tags
- How to add php within jquery
- Help with IF has focus then… statment
- What function actually renders the wp_admin_bar ? How can I call it?
- wp_enqueue_script() not working
- Removing the custom_image_header from wp_head
- Get URLs for AJAX Filter Checkboxes WordPress
- How to change text color depending on the number value (Using javascript)
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Add custom taxonomy using JS in post editor
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- How to fix Function create_function() is deprecated in / themes
- Exclude specific post from query
- Advanced method to control cache of enqueued style/script
- Display Script in Header When URL Variable Present
- WordPress wp_dequeue_script remove all other scripts
- Running javascript without hooking wp_head
- Populate Product Regular Price with a calculated ACF Field Value
- Header menu aligned right on all pages except for single-post page [closed]
- Override category archive page title (not the head title)
- Hide ‘add to cart’ when certain value in dropdown is selected
- Ajax Form Issues using Lightsail (AWS)
- Ajax Call not Working in Plugin
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- What is the earliest Hook a Script can use?
- WordPress does not load jQuery
- Class parameter in get_avatar args doesn’t get added to output
- post value to function with Ajax and jQuery
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- CSS style and app.js not loading
- Update $wpdb query with AJAX
- How to customize archive widget only for cpt?
- How to enqueue scripts properly with ES6 webpack?
- Ajax in plugin fails – but only on one blog – no idea why
- wp_title() return random number
- How to add javascript code into Divi child theme?