Divi: The best WordPress theme of all time!

With over 901.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates.

Would you like to display the number of your MailChimp subscribers? Recently one of our subscribers who requested the integration of MailChimp on his blog, wanted to know if it was possible to display the number of subscribers already registered to his newsletter.

Through this tutorial, I come to respond positively by showing you how to do it also at home (your blog).

Why display the number of subscribers on your blog?

Social proof has always had a positive impact on visitors. This will help encourage new subscribers to subscribe to your newsletter.

MailChimp is one of the most popular auto-responder services. We also have wrote a tutorial on it.

How to display the number of subscribers on your blog

In this tutorial, I will offer you two methods. The first through the use of a plugin and the second without plugin (for developers who want to learn).

First method: With the MailChimp Subscriber Chiclet plugin

All you have to do for this method is install and activate the plugin " MailChimp Subscriber Chiclet". After activating the plugin, you just need to navigate to the following location " Settings> MailChimp Subscriber Chiclet To configure the plugin.


Then you just need to provide the MailChimp API (You will find it in Reading this tutorial). All you need to do is log into your MailChimp account and access your account details.

Easily create your website with Elementor

Elementor lets you create Easily and Free any website or blog design with a professional look. Stop paying a lot for a website you can do yourself.


From this page, you will need to create a new API key, if you do not have one yet. Then copy this API key and go back to your WordPress dashboard on the plugin settings page. Right away " MailChimp API key“, Insert your API key and save your settings.

Once it's done, you will see the different email lists and select a list and configure it. Then you just have to copy the shortcode provided to add it to any page or article. You can also display it on your widgets.

Method two: How to display the number of subscribers using the MailChimp API

The method with the plugin displays the logo " Powered by MailChimp". You may not want to display this signature on your blog.

The following method will allow you to retrieve the number of subscribers yourself and display it on your blog. We go together create a plugin WordPress, and add the following code:

function bpc_mc_sub_count () {include "Mailchimp.php"; $ lastRunLog = 'logs / lastrun.log'; $ subfile = 'logs / subcount.log'; $ lastRun = file_get_contents ($ lastRunLog); if (time () - $ lastRun> = 86400) {$ MailChimp = new MailChimp ('Your API Key'); $ mc = $ MailChimp-> call ('lists / list'); $ subscriber_count. = $ mc [data] [0] [stats] [member_count]; file_put_contents ($ lastRunLog, time ()); file_put_contents ($ subfile, $ subscriber_count); } else {$ subscriber_count. = file_get_contents ($ subfile); } return number_format ($ subscriber_count); } add_shortcode ('mc-subscribers', 'bpc_mc_sub_count'); add_filter ('widget_text', 'do_shortcode'); 

Note: Don't forget to provide your API key to the class " MailChimp " page (in French).

Then create a folder that you will name logs. In this folder, create two empty files that you will rename "lastrun.log" and "subcount.log".


Now downloaded the MailChimp PHP Wrapper source code directly to the directory bitbucket. After downloading, extract the contents of the compressed file. you will notice a folder named "Src".


Copy the folder "MailChimp" and the file MailChimp.php At the root of your plugin.


All you need now is to activate your plugin. By using the [mc-subscribers] shortcode, you will be able to display the number of subscribers. Now with a little CSS tweaking, you can give it more style.

That's all there was to do. I would point out, however, that for all the tutorials that relate to the use of a custom plugin, you must always make a backup of your blog, or use a Environment for testing (recommended).

Please feel free to share this tutorial with your friends.