Installing Jquery sripts into wordpress
-
Hi can anyone point me to a tutorial on how to include jquery scripts I have tried the code below in my function.php but it doesn’t work.
[Code moderated as per the Forum Rules. Please use the pastebin]
-
I think they need to be registered to be enqueued….
http://codex.wordpress.org/Function_Reference/wp_register_script
How do i use pastebin I’ve copied my code into it but where do I connect it to my post
Sorry link to my code is below. I have placed all my assets and images in the root of my testsite child theme Im working in twenty eleven.
These are the jquery scripts that came with the slider.
jquery-1.6.1.min.js
jquery-ui-1.8.10.custom.min.js
jquery.wt-lightbox.js
jquery.wt-lightbox.min.js
jquery.wt-scroller.js
jquery.wt-scroller.min.js
slider.jsThis is in my functions.php to enque the scripts
http://pastebin.com/ULL7S2pWThis is slider.js and is in my js folder at the root of my child theme
http://pastebin.com/yssKsETjthis is the link to the plugin page
http://codecanyon.net/item/jquery-horizontal-image-scroller-w-lightbox/112734RE: see above
Thanks not sure if thats the problem I love this scroller just cant seem to get it to work in wordpress the guy who created it says its easy to install in WP beats me what I’m doing wrong.
This would be much easier to troubleshoot with a link to the test site.
You should also look at this: http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/ for information on using jQuery in WordPress using a noConflict wrapper to avoid trouble, and not using the ‘$’ shortcut.
Thanks (Jackson)
Think I’ve tried that method think I’ll try and find a plugin but so far found nothing similar to the codecanyon scroller above that’s avaailable.
I don’t know exactly what is affecting your script.
Try
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js' );
it will load script to the header (now it’s loading to the footer)add
array('jquery')to allwp_enqueue_scriptfunctions that loading jQuery scripts, e.g.
wp_enqueue_script('lightbox', get_bloginfo('template_directory').'/js/wt-lightbox.min.js', array('jquery'));The last one – may be it doesn’t work because of jQuery version – try to change version to 1.4.2 to check it.
Links to tutorials in the “Resources” section on this page
http://codex.wordpress.org/Function_Reference/wp_enqueue_scriptHi vjpo thanks for the advice, can i ask when you say “(now it’s loading to the footer)” do you literaly mean this is happening or is this an instruction to load from the footer, …Thanks
the code from your functions.php pastebin example
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1', true);
trueat the end of string places js script to the footer$in_footer = true<?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?>
http://codex.wordpress.org/Function_Reference/wp_register_scriptBut, by the way, did you resolve the issue?
No – thanks for the advice still cant get it to work I think with all the hassle related to this scroller, I think I’ll try to find a plugin that is similar just havn’t found one that works yet
http://codecanyon.net/item/jquery-horizontal-image-scroller-w-lightbox/112734
try to load your slider.js (second pastebin example) by this way.
Add this code to your functions.php// Load Dom Ready Javascripts function load_scroller_js() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { //initialize scroller // full scroller script here </script> <?php } add_action('wp_head', 'load_scroller_js');and exclude same script from the enqueue list
Thanks again vjpo still cant get it to work – works in the html example I downloaded – I’ll leave it and find a plugin – found one thats 90% there just judders every now and then it’s an iframe example here’s the link if anyone needs it
http://www.gopiplus.com/work/2011/07/24/wordpress-plugin-wp-iframe-images-gallery/
maybe I need to include something like this that targets the child theme
add_action(‘get_header’, ‘metric_load_scripts’);
function metric_load_scripts() {
wp_enqueue_script(‘follow’, CHILD_URL.’/lib/js/follow.js’, array(‘jquery’),’1′,TRUE);
}
The topic ‘Installing Jquery sripts into wordpress’ is closed to new replies.