Forums

Javascript on pages (8 posts)

  1. bombora
    Member
    Posted 3 years ago #

    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!

  2. iridiax
    Member
    Posted 3 years ago #

  3. Len
    Member
    Posted 3 years ago #

    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.

  4. bombora
    Member
    Posted 3 years ago #

    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.

  5. Len
    Member
    Posted 3 years ago #

    What is it you're trying to do specifically?

  6. bombora
    Member
    Posted 3 years ago #

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

  7. bombora
    Member
    Posted 3 years ago #

    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.

  8. Len
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic