• Hey, I’m trying to add a little javascript to my posts but NOT my main page. If I stick it in the header it works fine but it shows up on my index as well, so I just want it in the singlepost.php but it doesn’t work there, any help would be VERY appreciated 🙂

    PS I put:
    <script type=”text/javascript” src=”myscript.js”></script>

    in header.php and it works. I want this to load everytime someone views on my posts. Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • If I stick it in the header it works fine but it shows up on my index as well

    Yes because those theme files all call header.php

    I just want it in the singlepost.php

    You could try creating an exact copy of header.php – call it something like myheader.php – and it would contain the javascript you mentioned. Then in single.php replace…

    <?php get_header(); ?>

    … with …

    <?php include (TEMPLATEPATH . '/myheader.php'); ?>

    Also be sure to peruse the docs at the link iridiax gave you.

    Thread Starter bombora

    (@bombora)

    Its not working for me 🙁

    If anyone has another solution to execute some simple javascript when a post is viewed I will owe you forever. And yes I did read through all of those docs before starting this thread.

    What is it you’re trying to do specifically?

    Thread Starter bombora

    (@bombora)

    I’m trying to run a script that pops up when a user goes to my individual pages. This informs them that the content is ‘locked’ and they have to contact me to unlock it.

    I use this same script on HTML sites without a problem but am having a really tough time with wordpress for some reason 🙂

    Thread Starter bombora

    (@bombora)

    Nevermind it appears its working fine in IE but not firefox (and yes I have js enabled in ff 😉 ). So I guess its a different issue than I thought, thanks.

    Hi bombora. Glad to see you making some progress. Perhaps give the Firebug extension for Firefox a shot. One of the things it’s good at is debugging javascripts. Beyond that I’m out of ideas.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Javascript on pages’ is closed to new replies.