DevelopmentWeb Development and RedesignWordPress

How to Show WordPress Featured Images in MailChimp RSS – Without a Plugin

We’ve already gone through how to get featured images/blog post images to show in MailChimp with the Featured Image in RSS plugin, but perhaps you don’t want to use a plugin. Maybe you’re looking for a way to edit your RSS feed without putting yet another plugin into your WordPress install. Never fear! We can help guide you through this plugin-less route.

It’s actually quite simple. What we are going to do is create a custom page template that acts as our modified RSS feed. This is also a great way you can modify your RSS feed to serve only certain content, such as if you have more than one feed going at the same time.

Step 1: Create a new page template

This will reside inside of your WordPress theme’s folder. Much like header.php or footer.php, it will act similarly. If you’ve already made page templates before, you’ll know all of the required information, but we’re going to outline it for all of our first timers.

I am going to name the filename of my page template mailchimp.php. It doesn’t really matter what you name it, but you should make sure to use something that you won’t use in the future or won’t conflict with WordPress. That means probably refrain from using page.php, index.php, archives.php, etc. If you want to be ultra sure, you can also name the file name “rss-mailchimp.php” or otherwise.

Step 2: Add the required information at the top of the page document

Basically this tells WordPress that this file is a template, so it will be selectable on the right sidebar of your pages when you go to make it. Add this at the top:

Again, you can change the “template name” to anything you want, but I am going to name mine simply “MailChimp”

Step 3: Define your RSS items in your page template

You can copy this code to paste into your file after the code from step 2 and it will “just work”, but I will explain some of the items worth looking at to make sure that you have it just the way you want to.

Explanation of items of interest: $numposts is the number of posts in this feed. You can change it depending on what you’re doing with your feed. $posts, if you change the number on &cat=-1, can make it so your feed only serves posts made to a certain category. For example, if my category “advertising” is category ID 3, and I only wanted to send emails in the advertising category, I would change it to &cat=3

Important thing you need that is not in the standard RSS feed: You’ll notice under RSS version type there is an additional line: xmlns:media=”http://search.yahoo.com/mrss/” MailChimp uses media content blocks to read images, so you will need to first define that you are using this sort of markup with this line. I have then added after the category block 

Which basically says “if there is a featured image, get the URL for the full size of this featured image”, and then after that says “here is image media, here is the URL of it”, which is what MailChimp will then use to pull the image. You may want to define  a width parameter here if you are using the ‘full’ size featured images like I am, so you don’t end up making anyone’s inbox explode! Remember to always preview your campaigns before hitting send.

Step 4A: Make a page that uses this page template

Go into WordPress and click pages, then click add new. You will want to use the page attributes selector to pick your new “mailchimp” (or other name) template. Give your page a desired page slug (I am using /mailchimp, but you might want to use something else), and hit publish. You may also want to noindex this page as well.

Page Attributes in WordPress

If you don’t see “page attributes”, scroll to the top of the page and click “screen options”, then make sure “page attributes” is checked off. It should show now.

Screen Options

Step 4B: A Different method of adding your template…

Don’t want your template to take up space on your front end somewhere? Never fear! Let’s append it to /feed and keep all our RSS items in one spot. Add this code to functions.php:

In the above code, it will be looking for a file titled “rss-mailchimp.php”, but if you’ve just named it “mailchimp.php”, that’s OK too, just remove ‘rss’ from the array like so:

get_template_part(‘mailchimp’);

Step 5: Load your new URL into MailChimp

Instead of using /feed or /rss in your campaign setup, you’ll now want to use the URL you defined in step 4A. Mine will be http://www.website.com/mailchimp

For step 4B, your url will be http://www.website.com/feed/mailchimp

Step 6: Use the *|RSSITEM:IMAGE|* tag

This doesn’t work out of the box with WordPress and MailChimp, but it should be working now! Just place that merge tag where you want your image to appear, and when you test it, you should now see your featured images showing. Hooray!

Have questions or comments? Let us know below!

Want to get updates like this delivered straight to your inbox?
Subscribe to our blog to receive website design tips, development tricks, the latest in SEO, and more. We don't share your email address with anyone and you can unsubscribe at any time.
* indicates required

Leave a Reply

Your email address will not be published. Required fields are marked *