• My tracking software requires me to place a script in ONLY the home/index of my site, however, since WP is template based, the script will appear on every page; I am unsure how to accomplish this.

    -Scott

Viewing 7 replies - 1 through 7 (of 7 total)
  • <?php if(is_home() [ do stuff] ;?>

    Thread Starter cableghost

    (@cableghost)

    pardon my ignorance…do I place the script then inside the php call?

    Such as…<?php if(is_home() <script>do stuff</script> ;?>

    Or do I need an ending tag?

    -Scott

    <?php if(is_home()) { ?>
    CODE HERE..
    <?php } ?>
    Thread Starter cableghost

    (@cableghost)

    Thank you…Would I then place this in the first line of my main index or page template?

    -Scott

    Wherever your script needs to go (putting the PHP aside for a moment)..

    Your script still goes where it needs to, most likely in between <head> and </head> if it’s <script> kinda code…..

    No different to how you’d do it in a normal HTML page, the only difference here is it’s wrapped in the necessary PHP to conditionalise when the code is printed into the page..

    Thread Starter cableghost

    (@cableghost)

    Got it, thank you!

    Thread Starter cableghost

    (@cableghost)

    Actually, what if I wanted the script to reference a page other than the site’s Home page?

    I have a main site and another separate review site that I would like to combine. The review site, though it would become just a page on the main site, it will still have its own domain through redirection…how would I reference the script for only that page?

    -Scott

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do I add a script for just one page’ is closed to new replies.