cableghost
Member
Posted 4 months ago #
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
hedonplay
Member
Posted 4 months ago #
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.
cableghost
Member
Posted 4 months ago #
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 } ?>
hedonplay
Member
Posted 4 months ago #
Esmi is right, what I have shown is to run the scripts on both the home and others given pages.
cableghost
Member
Posted 4 months ago #