• Resolved cableghost

    (@cableghost)


    With help from other members, I have discovered I need the below php code in my header which will run my script only on my home page.

    However, how do I set it to run only on another, specific page? Do I put the slug of the page in place of ‘home’ in the below script?

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

    -Scott

Viewing 5 replies - 1 through 5 (of 5 total)
  • hello cableghost,
    to achieve this, you have to an ‘or’ condition inside ‘if’

    thing goes as follows:

    <?php if(is_home()||is_page(array(“please put your pages id here separated by comma”))) {} ?>

    don’t hesitate to contact me if it doesn’t work.

    Thread Starter cableghost

    (@cableghost)

    Thanks Hedonplay. But won’t adding this statement still leave the home page open to running the script?

    Let’s say Page ID 324 is the only page I want the script to run on…would your code, entered as below, work for me?

    <?php if(is_home()||is_page(array(“324”))) { ?>MY_SCRIPT_HERE<?php } ?>

    -Scott

    If you only want your script to work on page #324, then use:

    <?php if(is_page('324')) { ?>MY_SCRIPT_HERE<?php } ?>

    Esmi is right, what I have shown is to run the scripts on both the home and others given pages.

    Thread Starter cableghost

    (@cableghost)

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Script For One Page’ is closed to new replies.