Is the same as installing any other开发者_高级运维 wordpress plugins?
I'd supplement saibot's answer by saying that, instead of a raw <script>...</script>
block, you should use wp_enqueue_script()
also when including the plugin script:
<?php wp_enqueue_script("jquery-cookie", get_bloginfo('template_url').'/jquery.cookie.js', array(), '0'); ?>
Not really, you kind of have to go through the back door a little.
First off, make sure you're including jQuery the 'right' way (WP includes a copy):
<?php wp_enqueue_script("jquery"); ?>
In the header, include the plugin script the way you normally would, eg,
<script type='text/javascript' src='source/script.js'></script>
And then when you are writing your script, make sure it's in no-conflict mode:
(function($){
$(document).ready(function(){
//Scripts go in here!
});
})(jQuery);
And then stick the actual script inside the jQuery no-conflict wrapper.
Hope this helps.
And to make sure you're including jQuery, i'd supplement to Jani's answer:
<?php wp_enqueue_script("jquery-cookie", get_stylesheet_directory_uri().'/path/to/jquery.cookie.js', array( 'jquery' ), '0'); ?>
get_stylesheet_directory_uri()
would be just in case your script is located in a child-theme
Old thread i know, just wanted to share as it got me stuck for some time... until i added that 'jquery' in the array.
精彩评论