Grow your CSS skills. Land your dream job.

WordPress / Javascript problemo

  • # December 9, 2009 at 2:44 am

    Hey, anyone got some ideas?

    I have moved a static site into WordPress, adding an additional page for posts.
    I had javascript on the original site and it all worked when I moved it across.
    Now some of the javascript is working, others not. This was kind of sudden as it was all working yesterday.
    I was trying to get a pageloader to work, couldn’t. But I am pretty sure I have removed all traces of that.

    I am not sure what I am doing wrong. I think it might be something to do with including some of the code in the head?
    Here is my header code:

    Code:
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >


    < ?php if (is_page_template('suihome.php')) { ?>

    < ?php } ?>

    < ?php if (is_page_template('suiequipment.php')) { ?>

    < ?php } ?>

    < ?php if (is_page_template('suiequipment.php')) { ?>

    < ?php } ?>

    < ?php if (is_page_template('suiservices.php')) { ?>




    < ?php } ?>

    $page = str_replace(".php","",$page);
    $page = str_replace("?s","",$page);
    $page = $page ? $page : 'default'

    ?>

# December 10, 2009 at 2:45 am

You don’t have the wp_head(); tag… The wp_enqeue_script("jquery"); just says "Make sure to include Jquery when you spit out the wp_head… but you still need to put this code after that:

Code:
< ?php wp_head(); ?>

If you are still having trouble, after that:

Enable Firebug and tell me what error you are getting.
If you are getting the "$ is not a function error" you are having the exact same problem I am.

My "band-aid solution" is to include JQuery again after my wp_head():

Code:

I’ll probably have to post my own topic about it soon…

# December 10, 2009 at 3:27 am

Thanks Ashton,

I ended up using your ‘bandaid’ solution before I read the post.
It worked, but I will return to the project and try the other option.
I would like to do best practice if I can.

Thanks for the reply though,

BLUEBIRD

# December 10, 2009 at 3:40 am

Yea… just for emphasis:

If you have any plugins that need something in the head area (SEO, JS, etc.), that wp_head function is what does it. So not having that in the head will be the easiest way to break a plugin ;)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".