- This topic is empty.
-
AuthorPosts
-
July 4, 2009 at 3:41 pm #25353
JoshWhiteDesign
MemberOk, so I had a previous post that was just a false alarm. The real issue I think it’s boiled down to is that I can’t seem to get WP to execute any jquery or javascript from the header.php to any of my custom pages.
I have an index page setup as a custom page (http://www.citrusbunny.com) it’s the main one you are looking at.
Granted I’m fairly new to jquery, but I’ve successfully got it to work in a normal html page. This is the same issue I was having with the simplemodal contact form – the action doesn’t do anything on the page itself.
I used Chris’ "proper way" to include jscript into a WP template through the header.php, but that doesn’t seem to have helped.
Just an FYI – when I load any plugins that include jquery or anything else, it works just fine. I’d really like the ability to do some custom stuff, too though.
So what I have right now is:
header.php
Code:… blah blah blah …
in the stylesheet I have #contactslide defined as a 250px x 350px box with a black background just for testing. It’s supposed to slide up or down when you click the link "Contact Slide".
On the custom index page, I have:
Code:Read the rest of this page »‘); ?>
‘
Pages: ‘, ‘after’ => ‘
‘, ‘next_or_number’ => ‘number’)); ?>
‘, ‘
‘); ?>
So, I’m not sure what’s causing it to not function. My goal is that if I can figure out why this isn’t working, it will solve why I can’t get any jquery or foreign to WP scripts to work.
Does anyone have an immediate idea what I’m doing wrong?
July 4, 2009 at 4:37 pm #60189apostrophe
ParticipantTry changing $ to jQuery in your slide function.
July 5, 2009 at 2:27 am #60201apostrophe
ParticipantSo your script says
Code:jQuery(“#contactslide”).slideDown();but nowhere in your markup is there an element with the id of contactslide.
July 5, 2009 at 1:19 pm #60252davesgonebananas
MemberYou can’t "wp_enqueue_script" from a theme’s template. wp_enqueue_script is more for plugins really, but if you really want to use it you must call it from functions.php before the header has been output.
July 6, 2009 at 5:54 am #60300apostrophe
ParticipantQuote:It’s the in stylesheet.css file. I figured it would be easier than posting the entire thing :PWhat? :?
I’m looking at the page in the link you provided and nowhere on that page is there an element with the id of contactslide.Oh, and the page is loading jQuery fine.
July 6, 2009 at 10:59 am #60285davesgonebananas
MemberFirstly, to clarify what I said before you can use wp_enqueue_script but only if it appears before wp_head in the header. Sorry, I thought you were calling it from further down in the template, which was my mistake.
Secondly, Apostrophe is completely right you have no element with an id of contactslide, so this code will do nothing. You should create a contactslide div somewhere on the page for this to have any effect.
Code:contact slide contents
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.