I want a script (already working) now running on my entire WP website, except on one specific page, the page to which referral goes.
Script that works:
<script type="text/javascript">
var d = new Date();
var day = d.getDay();
if (day == 0) {
window.location="https://example.com/mypage";
}
</script>
I try to put the following code into my functions.php:
function my_custom_script() {
if ( is_page( 'mypage' ) ) { }
else {
var d = new Date();
var day = d.getDay();
if (day == 0) {
window.location="https://example.com/mypage";
}
}
}
add_action( 'wp_enqueue_scripts', 'my_custom_script' );
The reason I don't want the script to run on the redirect page is because the page will than run into an endless loop.
Can anyone tell me what to do to get it working?