Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionTrying to get my Mailchimp pop-up to only display on my homepage. Put this code in the site header but still show up on every page. What am I doing wrong?
<?php if(!is_front_page() || !is_home()){?>
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h).
[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}
(document,"script","
connected/js/users/bb98175c14cd48aeb0879ecff/.....js");</script>
<?php }?>
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionTrying to get my Mailchimp pop-up to only display on my homepage. Put this code in the site header but still show up on every page. What am I doing wrong?
<?php if(!is_front_page() || !is_home()){?>
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h).
[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}
(document,"script","https://chimpstatic/mcjs-
connected/js/users/bb98175c14cd48aeb0879ecff/.....js");</script>
<?php }?>
Share
Improve this question
asked Aug 17, 2020 at 1:46
Andrew Andrew
1
1 Answer
Reset to default 1You have a couple problems. First, the !
in the conditional means "NOT." Secondly, the ||
means "OR".
In other words, your conditional translates to:
If this is NOT the front page OR this is NOT the post archive page
That describes every page. Try this instead:
<?php if ( is_front_page() ) :?>
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h).
[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}
(document,"script","https://chimpstatic/mcjs-
connected/js/users/bb98175c14cd48aeb0879ecff/.....js");</script>
<?php endif; ?>
This says "If this is the front page, output the following code"