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
- 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
- AJAX handler throws 400 (Bad request) – why?
- How to Add a .js file Only in one specific Page Dynamically to Head
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- How to use WordPress (PHP) functions in AngularJS partials files?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Add inline css to theme
- How to enqueue JavaScript for specific WordPress pages only?
- Properly applying nonce to a form using AJAX
- Where does function_exists() look to decide whether a function exists? [closed]
- Ajaxing function in widget class
- Clean-up script tags
- Search user metadata with checkboxes via ajax (almost working)
- wp_enqueue JavaScript in child-theme (ReferenceError) using Search & Go
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- Including Javascript options
- How to remove howdy dropdown menu content
- Can’t load WP function into external function
- Why won’t my scripts load?
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- wp_register_script(… $in_footer = true) not working
- Theme functions.php file auto delete everyday [closed]
- Theme Javascript.php Overwritten Nightly [closed]
- Parse error after modifying the template menu [closed]
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Usage of theme name in functions
- PHP mixed with some JS code to update WordPress theme settings
- How do I link a button I created in theme customizer to a function?
- Load jquery only for certain pages in the backend
- Custom theme, contact form 7 & fast secure form doesn’t work
- ACF not showing
- Check if the image size is available and if not use ‘full’ image size
- Can we create our own theme’s function.php?
- Not all CSS elements transferring via parent to child?
- Define PHP variable from a seperate API if statement
- get_template_directory adding FTP root folders in urls
- Getting a ‘slide down’ js panel implemented within WP
- Filter nav menu items HTML tags and wrap inner text with span
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- The correct way to add a JavaScript in the functions.php [closed]
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- What is the correct way to include my new functions and scripts in WordPress?
- wp_nav_menu work in functions.php but not in the theme
- get content from page through AJAX
- How to make sure relative URL works when site is not on root domain?
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- colorbox not loading in
- Custom attributes to javascript tags
- wp_enqueue_script() not working
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- How to fix Function create_function() is deprecated in / themes
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- wp_title() return random number
- How to offset main query without affecting other queries and backend
- How to call a function from functions.php with ajax?
- Execute jQuery with custom event listener after successfully add an item to the cart
- HowTo: Add wrapper to columns shortcode?
- How to create admin ajax function for my contact form
- Load a Child Theme’s style.css just before the closing tag
- Ajax call does not work for this custom code
- Add the title of a widget as an ID – for anchor links
- Which template file to edit to edit homepage in Mystile [closed]