最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Mailchimp Popup on homepage only with is (front_page)

programmeradmin1浏览0评论
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 question

Trying 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 question

Trying 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
Add a comment  | 

1 Answer 1

Reset to default 1

You 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"

发布评论

评论列表(0)

  1. 暂无评论