Content MarketingEmail Marketing & Automation

Mailchimp: Building A Custom Feed In WordPress For Your RSS-to-Email Campaign

As resources continue to get tighter for companies, it’s becoming a necessity that they stop wasting time and fully incorporate automation and integrations that can shave hours of effort off of their workload every week. Companies often have marketing departments that are siloed by their work channels. A great example is a content team producing fantastic content and an email marketing team working on their weekly newsletter.

If you’ve got a blog, you likely have an RSS feed. And if you have an RSS feed with an email service provider that offers dynamic scripting in an email template, you can typically feed your blog posts directly to an email. Mailchimp’s RSS-to-Email feature does this beautifully…. and even schedules the newsletter for you!

Mailchimp RSS-to-Email

The RSS-to-Email feature is designed to simplify your email marketing efforts. Instead of manually creating email campaigns for each new post, Mailchimp automates the process. This allows you to focus on creating valuable content for your blog while Mailchimp takes care of email distribution.

Mailchimp’s RSS-to-Email feature works through steps that automate converting blog or website content into email newsletters and delivering them to subscribers. Here’s a detailed explanation of how it works:

  1. Integration Setup: To use the RSS-to-Email feature, integrate your blog or website’s RSS feed with Mailchimp. In Mailchimp, you can find an option to set up an RSS campaign.
  2. RSS Feed Fetching: Mailchimp will periodically check your RSS feed for any new updates once you’ve set up the integration. The frequency of this check can be customized based on your preferences. Whenever a new post or update is detected in your RSS feed, Mailchimp will initiate creating and sending your email campaign.
  3. Email Template Customization: Mailchimp offers a variety of customizable email templates. You can design or choose from pre-designed templates that suit your brand and preferences. The email template serves as the layout for your newsletter.
  4. Content Selection: The next step is to select the content included in the email campaign. Mailchimp will pull the latest posts or updates from your RSS feed and display them in the email using content blocks.
  5. Personalization and Design: Mailchimp lets you personalize the email by adding your branding elements, such as your logo, colors, and content formatting. You can also add personalized greetings and messages to engage your subscribers better.
  6. Scheduling: You can choose the specific day and time you want the email campaign sent to your subscribers. This scheduling feature allows you to send emails at optimal times, considering factors like time zones and engagement patterns.
  7. Automation: The entire process is automated with the RSS-to-Email feature set up. Whenever there’s new content on your blog or website, Mailchimp will automatically generate an email newsletter using the latest posts from the RSS feed and send it to your subscriber list based on your chosen schedule.
  8. Reporting and Analytics: Mailchimp provides detailed reports and analytics for each email campaign sent through the RSS-to-Email feature. You can track the performance of your emails, such as open rates, click-through rates, and subscriber engagement. These insights help you refine your marketing strategy and improve future campaigns.

Customizing Your RSS-to-Email Template

There are two elements to customizing your email, your email template and your feed. This section discusses how I’m customizing my email template utilizing merge tags to dynamically create the content utilizing data from the feed.

email editor rss to email mailchimp

Before The Feed

Before my feed, I wanted to display an email heading with the title of my RSS feed and the date that it was requested.

<h1 class="h1">*|RSSFEED:TITLE|*</h1>
Date: *|RSSFEED:DATE|*<br />

Feed and Items

Each of your posts within your feed is looped through as items.

<h2 class="mc-toc-title"><strong><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></strong></h2>

<p><span style="font-size:12px">by *|RSSITEM:AUTHOR|* on *|RSSITEM:DATE|*</span></p>

<div style="height: 9px; line-height: 9px;">&nbsp;</div>

<hr style="border: none; border-top: 2px solid #eaeaea; width: 100%; padding-bottom: 20px;" /> *|END:RSSITEMS|*

This sample Mailchimp RSS-to-Email template uses merge tags to insert content from the RSS feed into the email dynamically. Let’s explain each line:

  • *|RSSITEMS:|*: This is the merge tag used to indicate the start of the RSS feed items loop. Each item in the RSS feed will be processed as a separate email campaign with its content.
  • <h2 class="mc-toc-title"><strong><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></strong></h2>: This line generates an HTML <h2> heading with the title of the RSS feed item. The *|RSSITEM:URL|* merge tag is replaced with the URL of the item, and *|RSSITEM:TITLE|* is replaced with the title of the item.
  • <p><span style="font-size:12px">by *|RSSITEM:AUTHOR|* on *|RSSITEM:DATE|*</span></p>: This line creates a paragraph showing the author and date of the RSS feed item. *|RSSITEM:AUTHOR|* is replaced with the author’s name, and *|RSSITEM:DATE|* is replaced with the date of the item.
  • *|RSSITEM:IMAGE|*: This merge tag displays the image of the RSS feed item, typically the featured image. The image URL is inserted here.
  • <div style="height: 9px; line-height: 9px;">&nbsp;</div>: This line creates a 9px high empty space between the image and content. It uses a <div> element with a height of 9 pixels and a line-height of 9 pixels. The &nbsp; is used to ensure that the space is visible even in email clients that might collapse empty elements.
  • *|RSSITEM:CONTENT|*: This merge tag displays the content of the RSS feed item. It typically includes a snippet or excerpt from the original post.
  • <hr style="border: none; border-top: 2px solid #eaeaea; width: 100%; padding-bottom: 20px;" />: This line adds a horizontal line separator after each RSS feed item. The <hr> element with inline CSS styles creates a 2px tall horizontal line with a solid color of #eaeaea. The width: 100%; ensures that the line spans the full width of the email, and padding-bottom: 20px; adds a 20px space after the line.
  • *|END:RSSITEMS|*: This merge tag signals the end of the RSS feed items loop. Any content after this tag will be outside the loop and will not be repeated for each feed item.

The result is a nice, clean email incorporating a week of articles I’m sending out each Monday morning. You can subscribe here. If you want to add a table of contents to your email, I’ve got instructions on how to do that as well:

Add a Table of Contents To a Mailchimp RSS-to-Email Campaign

Build A Custom WordPress Feed For Email

Some additional customizations needed to be done, though, to make my emails look good:

  • I wanted to incorporate the featured image for each article into the final email.
  • I wanted to modify how long the excerpt of each article was so that there was enough content to engage my readers.
  • Because I’m sending my email newsletter out weekly, I want to ensure that I have an entire week of articles listed in the email rather than the default for my blog’s feed.
  • I didn’t want to modify my current RSS feed in any way because I’m utilizing that for some additional syndication efforts.

Well, with WordPress, you can accomplish this by making an additional feed! Here’s how:

  1. In your child theme’s functions.php file, add the following code to add a custom feed.
/ Register a custom RSS feed named 'mailchimp'
function custom_register_mailchimp_feed() {
    add_feed('mailchimp', 'custom_generate_mailchimp_feed');
add_action('init', 'custom_register_mailchimp_feed');

// Generate the 'mailchimp' feed content
function custom_generate_mailchimp_feed() {
    header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
    echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
    <rss version="2.0"
         <?php do_action('rss2_ns'); ?>>
        <title><?php bloginfo_rss('name'); ?></title>
        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
        <link><?php bloginfo_rss('url') ?></link>
        <description><?php bloginfo_rss('description') ?></description>
        <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
        <language><?php bloginfo_rss('language'); ?></language>
        <?php do_action('rss2_head'); ?>

        <?php while (have_posts()) : the_post(); ?>
                <title><?php the_title_rss(); ?></title>
                <link><?php the_permalink_rss(); ?></link>
                <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
                <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator>
                <guid isPermaLink="false"><?php the_guid(); ?></guid>
                <?php do_action('rss2_item'); ?>

                <!-- Add featured image as a media:content element -->
                <?php if (has_post_thumbnail()) : ?>
                    <?php $thumbnail_url = wp_get_attachment_image_url(get_post_thumbnail_id(), 'medium'); ?>
                    <?php if ($thumbnail_url) : ?>
                        <media:content url="<?php echo esc_url($thumbnail_url); ?>" medium="image" type="<?php echo esc_attr(get_post_mime_type(get_post_thumbnail_id())); ?>" />
                    <?php endif; ?>
                <?php endif; ?>

                <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
                <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
        <?php endwhile; ?>

// Load the template

Your new feed’s address will be your blog feed, followed by /mailchimp/. So, in my case, the Mailchimp RSS feed that I’m going to use is at:

Some important notes:

  • Be sure to update your permalink settings (you don’t have to change anything) to recognize and cache this new URL correctly.
  • If you’re modifying your feed and not seeing the latest data, WordPress caches your feed. A simple cheat is to add a querystring when requesting the feed. So, in the example above, I add ?t=1, t=2, t=3, etc., as I’m designating the feed in Mailchimp.

Want to see it in action? Subscribe below!

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

Back to top button