I don’t know why but when I display the source code for my WordPress page, there is <script src="ROOT/jquery">
before each script.
Loading it once in between the <head>
tags is enough. This leads to another script not working as expected. I read about a function called wp_enqueue
, but I don’t understand how it works.
here is the script it doesn’t work:
<script>
$(document).ready(function(){
//Datepicker Popups calender to Choose date
$(function(){
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: '1900:2050',
dateFormat: "dd/mm/yy"
//Pass the user selected date format
});
});
});
</script>
Can someone help me?
Thanks,
Daniele
UPDATED: See jQuery noConflict Wrappers in WordPress.
I tested this on a WordPress install locally and there were no more errors
UPDATE #2: This is now a CSS error.
Per this workaround, setting the z-index for each of your datepicker elements should do the trick:
wp_enqueue allows you to add more scripts and css to your site from the functions or any other action page like a plugin.
you must be including jquery already. wordpress by default includes jquery so you do not need to include it your self. check if you are including it in your theme and delete it.
you can not use
$()
with the wordpress jquery you need to usejQuery()
or: