Chykalophia Logo Color

Adding WP Featured Image To Mailchimp RSS Campaign

Sending out newsletter email to your client or your blog readers is one of the best approach to keep them into your inner circle. But sometimes, it took a while to prepare the content for your upcoming campaign or a special newsletter for them. There’s a simpler way: blog post! Yup, a simple blog post can do the trick. It really depends on what kind of information or offer you have on your blog post, nevertheless setting them into RSS newsletter campaign will save you time in preparing the newsletter campaign for your readers. Of course if you want to send them something exclusive and not the blog post, then this is definitely not your option.

In this post I’m not going to describe or guide you on how to set the RSS campaign for your blog post, especially if you’re using Mailchimp. Although, you can actually find more info and the guide on how to do that over here. Instead, I’m going to guide you on how to add the WordPress featured image to Mailchimp RSS to email campaign.

I originally created my RSS to email campaign with proper Mailchimp tag, but apparently my featured image from the WordPress blog post keep missing. So I’ve looked through some of the resources and other blog post related to this problem. It’s a bit scattered around, so I thought having the solution in one place would help others with the same problem.

As mentioned on the Mailchimp support about “How can I format the image content in my RSS to email campaigns?“, it is best to create a new custom RSS feed just for Mailchimp RSS campaign. So let’s start by creating a custom RSS feed.

If you’re not so proficient with web development then this article will help. It shows how to create a custom RSS feed and that’s what we’re going to use for this RSS campaign.

Your RSS feed template should be like this:
[crayon lang=”php”]
/*
Template Name: Custom Feed
*/

$numposts = 5;

function yoast_rss_date( $timestamp = null ) {
$timestamp = ($timestamp==null) ? time() : $timestamp;
echo date(DATE_RSS, $timestamp);
}

function yoast_rss_text_limit($string, $length, $replacer = ‘…’) {
$string = strip_tags($string);
if(strlen($string) > $length)
return (preg_match(‘/^(.*)W.*$/’, substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
return $string;
}

$posts = query_posts(‘showposts=’.$numposts);

$lastpost = $numposts – 1;

header(“Content-Type: application/rss+xml; charset=UTF-8”);
echo ‘‘;
?>

http://YOURWEB.com/ The latest blog posts from YOURWEB.com.
en-us

 

post_date_gmt) ); ?>

post_date_gmt) ); ?>
[email protected]

 

 

ID); ?>

post_content, 500).’

Keep on reading: ‘.get_the_title($post->ID).’‘.’]]>’;  ?>

 

post_date_gmt) ); ?>

ID); ?>

[/crayon]

 

In order to be able to pull the WordPress featured image, we’re going to add:
[crayon lang=”php”]


[/crayon]

So, your final PHP file will be like this:
[crayon lang=”php”]
/*
Template Name: Custom Feed
*/

$numposts = 5;

function yoast_rss_date( $timestamp = null ) {
$timestamp = ($timestamp==null) ? time() : $timestamp;
echo date(DATE_RSS, $timestamp);
}

function yoast_rss_text_limit($string, $length, $replacer = ‘…’) {
$string = strip_tags($string);
if(strlen($string) > $length)
return (preg_match(‘/^(.*)W.*$/’, substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
return $string;
}

$posts = query_posts(‘showposts=’.$numposts);

$lastpost = $numposts – 1;

header(“Content-Type: application/rss+xml; charset=UTF-8”);
echo ‘‘;
?>

http://YOURWEB.com/ The latest blog posts from YOURWEB.com.
en-us

 

post_date_gmt) ); ?>

post_date_gmt) ); ?>
[email protected]

 

 

ID); ?>


post_content, 500).’

Keep on reading: ‘.get_the_title($post->ID).’‘.’]]>’;  ?>

 

post_date_gmt) ); ?>

ID); ?>

[/crayon]

 

Once you uploaded the PHP template file above to your WordPress theme folder, follow the instructions as mentioned on the Yoast blog post, which are:

  • Create a new page (which can be blank), with a secret URL,
  • Use your newly created “Custom Feed” template for that page,
  • Open the secret URL in your browser and now you should have a custom RSS feed for the Mailchimp RSS campaign.

Next step, you should replace the RSS feed address (refer to the custom RSS URL page you just created) where your your Mailchimp RSS campaign is reading from. And make sure to also include the Mailchimp merge tag *|RSSITEM:IMAGE|* or *|FEEDITEM:IMAGE|*

Here’s the sample of my RSS email newsletter based on this mini tutorial.

Credit:
Original resource for the featured image code.

Sign up for our Next Draft newsletter

Get our top branding, UX and website resources for your business straight to your inbox.

Resources Page Mega Email Signup

This will add you to our Next Draft list where we send out useful content around branding, marketing, and all things website that help inspire growth for you and your business. Of course you can unsubscribe anytime.

Get started on a branding or website project with us.

GET ON A CALLBook a brand, ux, or web audit