根据 wordpress 类别通过电子邮件将博客文章发送到组

Sending blog posts via email to groups based on wordpress categories

当我 post wordpress 博客中的一篇文章并将其分配给多个类别时,是否有一种简单的方法可以将完整的 post 发送到 mailchimp 中列表中的特定组?例如,当我 post 一篇文章并将其分配到类别 A、B 和 C 时......我想自动化一个过程来获取该博客的内容 post 并通过电子邮件将其发送到组A、B 和 C 在 mailchimp 的单个列表中。

我尝试在 mailchimp 中使用 RSS 到电子邮件活动,但这不允许我根据为博客选择的类别自动发送到动态组 post。

我当然愿意接受可以实现我的目标的插件。实际上,我更喜欢支持良好的插件。

您可以使用 publish_post 操作来实现您想要的。 add_action( 'publish_post', 'send_email_after_post_published', 10, 2 );

现在,创建处理电子邮件功能的函数

function send_email_after_post_published($ID, $post){
    if($post->post_type==='post'){
        $categories=get_the_category( $post->ID );
        //now you can send email according to the category 
    }
}

有关详细信息,请参阅此处 https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post