I enjoy simplicity, in everything. Unnecessary complexity is evil. Have a look at my WordPress plugins.

Automatically add a MailChimp sign-up form to all posts

When someone gets to the end of your post, they surely love what you have to say. It makes the end of your posts the perfect spot to ask your visitors to sign-up to your newsletter. It converts well and you’re asking right when they’re feeling great about your content.

In this post I’ll show you a small snippet you can use on your WordPress website. This snippet will automatically add a sign-up form to the end of all your posts, without having to go through all of them individually (which is madness).


There are various ways to go about this but the easiest way is to use a filter, like I did in the following code snippet. All you need to do is to add this snippet to your theme functions.php file (use the Theme Editor or FTP for this) and you’re good to go.

If you’re using the premium version of MailChimp for WordPress, don’t forget to change 000 into the ID of the sign-up form you wish to show.

Please be careful implementing the above snippet if you’re not comfortable with PHP and/or editing functions.php files. It’s easy to break your website if you’re not following the correct PHP syntax.

Questions? Ask away in the comments!

Share this post: on Twitter on Facebook

23 Responses to “Automatically add a MailChimp sign-up form to all posts”

    • Hi Gary,

      Yes, at the end or beginning of your theme its functions.php file would be a good place to add this snippet. If you’re copying the snippet entirely, don’t copy the opening < ?php tag with it. That's probably what broke your site..

  1. Danny, I am a semi-hopeless rookie at all of this and I have been round and round the Internet trying to find the answer. I have your pro version of the plug-in on a WeaverII themed wordpress site. (Just upgraded to pro thinking all those neat forms would be automatically available without me having to do any coding. Oops, I was wrong!)

    I want to have a comments section at the bottom of each post. One just like this will do. Eventually, I want it all to be linked to social networks ( I think), but that’s another plug in – one thing at a time. If I understand this correctly, I need to add the following code to the functions.php file (Did I change the 000 correctly?) And this will get me what you have here?

    // ...........................
    // your functions.php contents
    function mytheme_add_signup_form_to_posts( $content ) {
        // Check if this is a single post. 
        if ( is_single() &amp;&amp; get_post_type() == 'post' ) {
            // Add the form to the end of the post content.
            // Replace '000' with the ID of the form you would like to show
            $content .= mc4wp_get_form(0);
        // Returns the content.
        return $content;
    add_filter( 'the_content', 'mytheme_add_signup_form_to_posts' );

    Thank you so much for your help. I’m already subscribed to your newsletter.


    • Hi Glenn,

      Almost there! You need to replace the 0 (zero) with the ID of the sign-up form you’re trying to show. Have a look at the shortcode for that form on the “edit form” page, which should look somewhat like this: [mc4wp_form id="321"]. In this case, 321 is the ID of the form.

      As you’re running the Pro version, don’t hesitate to shoot me a direct email – I’d be happy to help you out!


  2. Hi Danny,

    If you don’t mind, I’m going to leave my questions here just for the next rookie that might be going through the same confusion that I am – maybe it will shorten their learning curve. (Unless you want to take it offline because my questions are too, too elementary for the comment section – your choice).

    When I go to MailChimp for WP forms, the only form listed there is the one I created on the mail chimp website for an initial mailing list. There are no other forms like the one on your page: http://dannyvankooten.com/mailchimp-for-wordpress/

    When I upgraded to your pro version, I uploaded the zip file, entered the code you sent me, and the screen showed activated so I think I installed the upgrade correctly. Oh, and I disactivated MailChimp for WordPress Lite .

    Thanks for helping me right at Christmas…

    • Hi Glenn,

      From the sounds of it the upgrade went just fine. Good! The Pro version allows you to have multiple sign-up forms though, so we need to tell the plugin which form to show after your post content (even if you have only one form, although this leaves room for a great improvement for a future version of the plugin – thanks).

      Each form, like WordPress posts, has a unique ID. The easiest way to get this ID is by taking a look at the shortcode, it should be listed in several places on the MailChimp for WP > Forms settings page.

      If you want, you can also send me an URL to a page on your website that has your sign-up form on it. I can discover the ID for you by taking a look at the page source. :-)

      Hope that helps Glenn, happy 2nd Christmas day!

  3. Just wanted to publicly say, “Thank you,” to Danny for helping me directly through email. I didn’t want any potential clients to think he dropped the discussion half way because he did just the opposite – he followed it all the way through the labyrinth of my confusion. I am a fan!

  4. Hi Danny,

    I just pasted the snippet above (excluding the <?php bit) and now I can't see my site. Cant access the dashboard. Yikes! A little help please.


  5. Hi Danny,

    How do I add something similar to you have on your website for form sign-up? When someone scroll down it shows on left hand side of the screen. Your sign-up form “Become a better WordPress developer”

    Thank You

Leave a Reply