Run PHP once in Wordpress page
Posted on 2011-03-04
I have a Wordpress site that I am trying to add some custom PHP to, which I would only like to run once. My Wordpress pages all use the script within "page.php" of my theme to create every page.
So if I go to my "Home" page it renders that page using "page.php". If I click on the "Contact" page it renders that page by again using the "page.php" from my theme. At least, this is my understanding of how the theme works.
I'm trying to add some script to my "page.php" file that will run the FIRST time that "page.php" is loaded and never again. Basically, someone comes to the home page and that script is run, but if they click "Contact", the script doesn't get run again when "page.php" is reloaded. I've tried using a session variable called $_SESSION['check'] but it's not working correctly.
Any ideas you can provide would be helpful and please don't hesitate to let me know if I haven't provided enough info. Thank you!!