Adding JQuery using functions.php
-
I have a signup form with some personalised JQuery styling I’ve been trying to add to my blog sidebar:
It pretty simple: an image and sign up box. Without javascript working the signup box sits below the image. When it works the signupbox should be hidden and revealed when the image is clicked on.
I’ve tested that it works outside of wordpress but having no joy trying to implement in wordpress.
The components are:
• Javascript for a mailchimp signup form : form.js
• My bit of jquery that calls the slidetoggle function: signup3.js
• The jquery library itself: https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
• The related css styling: style.cssI’ve been looking at several useful resources to help:
http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/
http://themocracy.com/2010/01/more-wordpress-and-jquery/
http://www.webtechwise.com/add-jquery-to-wordpress-blog-without-plugins/
…but still no joySo far I’ve added the css styling to the theme style.css doc and got pasted the following into the functions.php:
function my_init() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2', true); wp_enqueue_script('my_script', get_bloginfo('template_url') . '/js/signup3.js', array('jquery'), '1.0', true); wp_enqueue_script('jquery'); } } add_action('init', 'my_init');(I haven’t included mailchimp’s form.js yet because 1) I want to concentrate on getting the jquery functionality working first and it should work with or without form.js 2) I’m not sure how to additionally include a reference to it in the above script anyway.
I’ve wrapped my jquery in the signup3.js doc with
(function($) { CODE IN HERE })(jQuery);Any advice would be really appreciated
Thanks!
The topic ‘Adding JQuery using functions.php’ is closed to new replies.