简体   繁体   中英

MailChimp Pop-up form on-click for WordPress Menu Item

I'm having issues implementing a simple click on a menu item in the header of a website I am working on that opens a pop-up window for a subscribe form that's generated by MailChimp.

Furthermore, I have reviewed the other posts about this topic on here and Github and nothing seems to be working.

Here are a couple of post examples I've reviewed but don't appear to be working:

Here is what I have so far:

Header File

This is stored in the <head> so this will load before the menu items.

<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>

<script type="text/javascript"> function showMailingPopUp() {
    require(["mojo/signup-forms/Loader"], function(L) {
        L.start({
            "baseUrl": "mc.us18.list-manage.com",
            "uuid": "myUUID",
            "lid": "myLID"
        })
    }) 
document.cookie = 'MCEvilPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
};
$(function() {
    $(".subscribe a").on('click', function() {
        showMailingPopUp();
    });
}); 
</script>

Note the .subscribe is a class that is assigned to the menu item shown below: WordPress仪表板外观菜单项
Here's the source code:

<li id="menu-item-171" class="subscribe menu-item menu-item-type-custom menu-item-object-custom current_page_item menu-item-home no-mega-menu"><a class="menu-item-link js-smooth-scroll" href="https://thiswebsite.com/#subscribe">Subscribe</a></li>

Any help would be greatly appreciated!

刚结束时,而是分享您的注册表单mailchimp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM