I am having kittens trying to figure this out. And i have literally been at it two full days, and am genuinely surprised i have the laptop in my hands, and not in pieces ;[_
Anyway, a few details before i move onward.
my site: http://www.gotodesigns.co.uk is using a child theme of the TwentyEleven theme.
I have a few custom template pages, nothing special really. The problem is i`m having a hard time stretching my head around where to call my jQuery from and where in my child theme to put the code, i have a couple of scripts im trying to run here on my <a href=”http://www.gotodesigns.co.uk/contact/”>contact page</a>
First one is a jQuery navigation strip that is supposed to drop down on hover, here is a link to the <a href=”http://www.the-puzzle.co.il/slipslap/”>original demo website</a>
And another one is a simple hover sliding box/caption hover plugin from <a href=”http://buildinternet.com/project/mosaic/1.0/”>this website</a>
I will start by linking to my header file just to show you whats going on in there: http://pastebin.com/6YTjk9Zz
Then my functions.php: http://pastebin.com/d28B0878
As you can see, not much going on here, as the child’s function.php overrides the parent. Only needed to tweak the excerpt thus far..
Now for the CSS that relates to each plugin.
Firstly the navigation plugin: http://pastebin.com/a7H1j64U
Now the hover plugin: http://pastebin.com/4qgCmT3H
These styles are pasted directly in my main css file, so you can obviously view the entire stylesheet from my website should the need arise.
Now i have used the contact me page on my site to test out these scripts, so all the html resides within that page, so you can firebug that.
Now, am i right in saying it is better to call the main jquery from http://ajax.googleapis.com. Ant THEN underneath call the plugins individually from the child themes js folder? As opposed to including the paths in the header, as it`s a child theme.
I have tried these:
<?php wp_enqueue_script(‘slipSlap.js’, ‘wp-content/themes/twentyeleven-child/js/slipSlap.js’, array(‘jquery’)); ?>
In the header, with wp_enqueue_script(‘jquery’); before the head section in the header, as many blog posts and articles seem to relate to. But again to no avail.
So how exactly is one “supposed” to do this from within a child theme? I come from a background where i made a few static websites and always the jQuery worked when called. I know WordPress does things differently, and i`m sure for a very good reason, it just seems convoluted to the newbie 😉
On my last attempt at including the jQuery in functions.php (as can be seen in the second pastebin example)i noticed that the navigation menu for the jQuery plugin i mentioned earlier seems to be trying to call some script, as when you hover over each link the bottom of the link areas stay orange, and doesn’t reset until you refresh the page.
I notice also that the calls to the plugin are located in the footer area when i view the source, is this correct and why please?
Another point is do i need to add the jQuery to function calls that exist already with ‘$’ for the jQuery noConflict mode, or once i have it running am i good to go without changing it all the time?
So finally, do i need to call anything in my header.php related to jQuery, remembering still that this is a child theme. Or do i do all of it from functions.php and only include the script i want on my header.php, for example:
<?php wp_head(); ?>
Sorry to ask so many questions in one sitting, but i really would like to make sure i have all the angles covered.
Many kind regards
- The topic ‘[Theme: Twenty Eleven] wp_enqueue_script problems’ is closed to new replies.