Just a warning, I am totally new to PHP and coding in general so please bear with me.
Here is what I am attempting to do: Our company's wordpress website ( http://www.vectormedia.com ) uses lightbox to display a video when the homepage is loaded. I'd like to make it so that if you have visited the website in the past week, the video will not appear.
Here is my code:
At the very top of the header.php of my wordpress theme is the function to create the cookie:
<?php
function cookies() //Sets cookie function for video
{
$expire = time()+60*60*24*7; //cookie expiration (7days)
setcookie("video", "vector", $expire);
}
?>
Here is the variable that will load the video embedded in lightbox (also located in header.php):
<?php
//defines javaload as lightbox script with embeded video
$javaload = '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.lightbox("https://www.vimeo.com/36697123");
});
</script>'
?>
Here is the If statement located in the footer.php that checks to see if the cookie exists and if we are on the homepage, if true then load the video and set the cookie:
<?php
if ( !isset($_COOKIE["video"])) && (is_front_page());
echo $javaload
echo cookies();
?>
The problems are:
a) this code simply doesn't work.
b) it's also breaking my submenu rollovers
And my questions are:
a) why doesn't this work?
b) why is it breaking my menu?
c) is there a better way to accomplish this?
Any help will be greatly appreciated, thanks in advance.