
邮件黑猩猩教程
Do you want to display your MailChimp subscriber count? Recently one of our users asked us how they can show their MailChimp subscriber count in WordPress. Displaying 社会证明 encourages other users to join your newsletter. In this article, we will show you how to show your MailChimp subscriber count in WordPress.
您要显示您的MailChimp订阅者数量吗? 最近,我们的一位用户问我们如何在WordPress中显示其MailChimp订阅者人数。 显示社会证明会议鼓励其他用户加入您的新闻通讯。 在本文中,我们将向您展示如何在WordPress中显示MailChimp订阅者人数。
邮件黑猩猩 is one of the most beginner friendly email marketing service provider. If you are not already using MailChimp, then check out our guide on 将 MailChimp 与 WordPress 结合使用.
邮件黑猩猩是最适合初学者的电子邮件营销服务提供商之一。 如果您尚未使用MailChimp,请查看有关将 MailChimp 与 WordPress 结合使用的指南。
我们将展示两种不同的方法来显示 MailChimp 订阅者数量。第一种方法更简单,需要安装 WordPress 插件。第二种方法更高级,您需要根据不同的源文件创建一个插件。如果您不习惯编辑代码片段,那么我们建议您使用第一种方法。
我们将展示两种不同的方式来显示 MailChimp 订阅者数量。第一种方法比较简单,需要安装 WordPress 插件。第二种方法更高级,您需要根据不同的源文件创建一个插件。如果您不喜欢编辑代码片段,那么我们建议使用第一种方法。
方法1:使用MailChimp订阅服务器Chiclet插件 (Method 1: Using MailChimp Subscriber Chiclet Plugin)
First thing you need to do is install and activate the MailChimp 订阅者 Chiclet plugin. Upon activation, visit 设置 » MailChimp 订阅者 Chiclet to configure the plugin.
您需要做的第一件事是安装并激活MailChimp 订阅者 Chiclet插件。 激活后,访问设置 » MailChimp 订阅者 Chiclet来配置插件。

First you will need to enter your MailChimp API key. If you haven’t created one, then you can login to your 邮件黑猩猩 account dashboard and get one.
首先,您需要输入MailChimp API密钥。 如果尚未创建一个,则可以登录到邮件黑猩猩帐户仪表板并获取一个。

输入 API 密钥后,单击“保存更改”按钮。然后该插件将从您的 MailChimp 帐户加载您的电子邮件列表。选择您的电子邮件列表并配置插件设置。
输入 API 密钥后,单击“保存更改”按钮。然后该插件将从您的 MailChimp 帐户加载您的电子邮件列表。选择您的电子邮件列表并配置插件设置。
完成后,只需从插件底部复制短代码并将其添加到您想要显示订阅者数量的任何帖子、页面或文本小部件中。
完成后,只需从插件底部复制短代码并将其添加到您想要显示订阅者数量的任何帖子、页面或文本小部件。

方法2:使用MailChimp API获取订阅者计数 (Method 2: Getting Subscriber Count Using MailChimp API)
您会注意到,使用插件方法您可以通过由 MailChimp 徽标提供支持的订阅者数量。许多用户只想获得该号码,以便他们可以将其与自己的电子邮件注册表单一起使用。
您会注意到,使用插件方法您可以通过 MailChimp 徽标获取订阅者数量。许多用户只是想获得该号码,以便可以将其与自己的电子邮件注册表单一起使用。
在这种方法中,我们将创建一个插件。该插件将使用 MailChimp 的 API 来获取订阅者数量。您将能够使用简码在任何您想要的地方显示订阅者数量。
在这个方法中我们将创建一个插件。该插件将使用 MailChimp 的 API 来获取订阅者数量。您将能够使用简码在任何地方显示您的订阅者数量。
步骤1: First thing you need to do is to create a folder on your desktop and name it mc-subscriber-count.
步骤1:首先,您需要在桌面上创建一个文件夹,并将其命名为mc-subscriber-count。
第2步 Inside the folder create a new file and name it mc-subscriber-count.php and paste this code inside it.
第2步在文件夹中创建一个新文件,并将其命名为mc-subscriber-count.php并将此代码粘贴到其中。
重要的: Don’t forget to replace Your_MailChimp_API_Key with your actual MailChimp API Key.
重要提示:不要忘记用实际的MailChimp API密钥替换Your_MailChimp_API_Key。
<?php
/*
Plugin Name: MailChimp Subscriber Count
Plugin URI: https://www.wpbeginner.com
Description: Retrieves MailChimp subscriber count and displays it as a text
Version: 1.0
Author: WPBeginner
Author URI: https://www.wpbeginner.com
*/
function wpb_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_MailChimp_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', 'wpb_mc_sub_count');
add_filter('widget_text', 'do_shortcode');
?>
步骤3: Inside mc-subscriber-count folder create another folder and name it logs. Inside the logs folder create two blank files using a plain text editor like Notepad. Name one file lastrun.log and the other subcount.log.
步骤3:在mc-subscriber-count文件夹中,创建另一个文件夹并命名为log。 在日志文件夹内,使用纯文本编辑器(如记事本)创建两个空白文件。 将一个文件命名为lastrun.log,将另一个命名为subcount.log。

步骤4: Download the MailChimp PHP Wrapper source code from MailChimp 存储库. Download link is located at the bottom in the right hand column.
步骤4:从MailChimp 存储库下载MailChimp PHP Wrapper源代码。 下载链接位于右列的底部。
下载后,您需要解压 zip 文件。在提取的文件夹中,您将看到一个包含 Mailchimp.php 文件和 Mailchimp 文件夹的文件夹 src。
下载后,您需要解压 zip 文件。在解压的文件夹中,您将看到一个 src 文件夹,其中包含 Mailchimp.php 文件和 Mailchimp 文件夹。

第5步: Copy and paste Mailchimp.php file and Mailchimp folder to your plugin folder.
第5步:复制Mailchimp.php文件和Mailchimp文件夹并将其粘贴到您的插件文件夹中。

第6步: Upload mc-subscriber-count folder to /wp-content/plugins/ folder on your website using an FTP client.
第6步:使用FTP客户端将mc-subscriber-count文件夹上传到您网站上的/ wp-content / plugins /文件夹。
第7步: Visit the Plugins page on your WordPress admin area and activate MailChimp Subscriber Count plugin.
第7步:访问WordPress管理区域上的“插件”页面,然后激活MailChimp订户计数插件。
步骤8: Use shortcode [mc-subscribers]
to display MailChimp subscriber count in any post, page, or text widget in WordPress.
步骤8:使用简码[mc-subscribers]
在WordPress中的任何帖子,页面或文本小部件中显示MailChimp订阅者计数。
我们希望本文能帮助您在 WordPress 网站上以文本形式显示 MailChimp 订阅者计数。
我们希望本文能帮助您在 WordPress 网站上以文本形式显示 MailChimp 订阅者计数。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-show-your-mailchimp-subscriber-count-in-wordpress/
邮件黑猩猩教程