nipponese
Member
Posted 2 months ago #
Lately I have been having a ton of problems with plugins that use JQuery to display their AJAX calls. I assume the problem comes from the fact that I am calling my own local copy of JQuery 1.3.2 in header.php. The list of plugins that cause problems is not short or obscure, including Contact Form 7 and Google Analyticator.
Currently I am using something that looks like this:
<script src="<?php bloginfo('template_directory') ?>/js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<?php wp_head(); // For plugins ?>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
//JQuery stuff
});
</script>
The WP way to add jQuery to your theme header is add this line
<?php wp_enqueue_script('jquery'); ?>
BEFORE
<?php wp_head(); ?>
Then WP loads it only if its not already loaded. That way everything in WP is using the same copy of jQuery
dtiger2k
Member
Posted 2 months ago #
Try using the $ in there to express jQuery qlobal object.
<script src="<?php bloginfo('template_directory')</script>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"charset="utf-8">
jQuery(document).ready(function($) {
});
</script>
<?php wp_head(); ?>
nipponese
Member
Posted 2 months ago #
Neither of these seem to help.
<?php wp_enqueue_script('jquery'); ?> disregards everything in jQuery(document).ready(function($) {
and adding the $ has no effect.
nipponese
Member
Posted 2 months ago #
Do you think it matters that I am using a few JQuery plugins?
<script src="<?php bloginfo('template_directory') ?>/js/jquery-ui-1.7.2.custom.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php bloginfo('template_directory') ?>/js/jquery.cycle.all.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php bloginfo('template_directory') ?>/js/jquery.easing.1.3.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php bloginfo('template_directory') ?>/js/thickbox.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php bloginfo('template_directory') ?>/js/jScrollPane.js" type="text/javascript" charset="utf-8"></script>
Should not matter. From an older theme:
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/jquery.prettyPhoto.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto({
animationSpeed: 'normal', /* fast/slow/normal */
padding: 40, /* padding for each side of the picture */
opacity: 0.35, /* Value betwee 0 and 1 */
showTitle: false, /* true/false */
allowresize: false, /* true/false */
counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
callback: function(){}
});
});
</script>
<?php wp_head(); ?>
Peter
nipponese
Member
Posted 2 months ago #
I see the problem now... It's my use of JQuery UI and Thickbox. Replaced my script tags for those scripts with:
<?php wp_enqueue_script('query-ui-core'); ?>
<?php wp_enqueue_script('thickbox'); ?>
WP does NOT play nice with scripts that come already packaged.
lilqhgal
Member
Posted 1 month ago #
nipponese, I'm having the same issue trying to get some plugins that already have jQuery and one that I have hard-coded into my theme (a content slider which is part of the design)... I'm not exactly sure how to use your above posted code to apply to my situation. It works FINE with my code below, UNTIL a plugin that uses jQuery is activated. Here is my code:
<script src="/js/jquery-1.2.6.js" type="text/javascript"></script>
<script src="/js/jquery.scrollTo-1.3.3.js" type="text/javascript"></script>
<script src="/js/jquery.localscroll-1.2.5.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/jquery.serialScroll-1.2.1.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/coda-slider.js" type="text/javascript" charset="utf-8"></script>
Any suggestions are appreciated!!!
alekone
Member
Posted 2 weeks ago #
lilqhgal I have the same exact problem with the same plugins.
help, somebody!