The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Can’t seem to get any jscript to work in WP

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #25353

    Ok, 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 ( 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:



    … 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:


    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?


    Try changing $ to jQuery in your slide function.


    So your script says


    but nowhere in your markup is there an element with the id of contactslide.


    You 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.

    It’s the in stylesheet.css file. I figured it would be easier than posting the entire thing :P

    What? :?
    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.


    Firstly, 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.


    contact slide contents

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.