Build a ‘WordBurner’ Email Newsletter Manager using WordPress and FeedBurner
May 17th in Wordpress by Paul Burgess
There are lots of different ways to communicate with your users these days. RSS feeds, SMS, & sites like Twitter have changed how we speak to our audience. But for my money, you can't beat the personal touch of a good ol' email newsletter.
Of course keeping up a newsletter can take effort, but in this tutorial I'll show you how to use your regular Wordpress website combined with Feedburner to make a simple email newsletter manager.
Paul Burgess is a web designer based in Brighton, UK, raised on hip hop, design and a mild internet addiction.
There are many dedicated and great email newsletter solutions on the market. This is not intended to replace them, but rather to offer an easy way to email visitors of your personal site or blog a round up of updates and news without having to install new software or set up new systems.
What we are going to do is:
- Create a 'Newsletter' category in Wordpress
- Hide it from regular posts
- Create an RSS feed for that category
- Give that feed to FeedBurner and use their email update service to deliver our newsletter.
This tutorial is based on the default theme in Wordpress 2.5.1. If you are using a different theme, some code may be in a slightly different place and you may have a few extra files, but the principles are still the same.
Once you're all set up, sending out an email newletter will be as easy as writing a blog post, so let's get started!
Step 1 - The 'Newsletter' category
First of all we create a new category in Wordpress called 'Newsletter'. Sign in to your admin area and go to Manage > Categories - click Add New. For Category Name let's choose 'Newsletter' and Category Slug will be 'newsletter' and click 'Add Category'.
With our Newletter category created, we need to get its ID. Since Wordpress version 2.5, seeing a category's ID has become a little tricky, the best way to see it is to hover over the category in Manage > Categories and look at the status bar in your browser for the cat_ID part of the link as shown in the screenshot below:
In this example, our category ID id is 6. This number will probably be different for you, make a note of it.
For the rest of this tutorial you will see this number represented by {YOUR cat_ID}. Wherever you see {YOUR cat_ID}, replace this with your number.
Step 2 - Hiding the 'Newsletter' category
Now we should hide this category away from our main blog/site. Firstly we'll hide it from the category list that appears in the Wordpress sidebar. A category will only show in the sidebar when it has at least one post assigned to it, therefore the Newsletter category will not show until we write and publish a post for it. But we don't want that to happen, so...
Open up your theme's sidebar.php file (/wp-content/themes/your-theme-name/sidebar.php) and look for:
wp_list_categories('show_count=1&title_li=<h2>Categories</h2>');
Change this to:
wp_list_categories('show_count=1&exclude={YOUR cat_ID}&title_li=<h2>Categories</h2>');
This will exclude our Newsletter category from showing up in the category list in our sidebar. (Ref.)
Step 3 - Hide Posts
Next, we want to stop our newsletters from showing up in our regular posts. Excluding categories from 'The Loop' (where Wordpress displays our posts) seems to be a bit problematic. After trying this way and that way, there were still problems with paging breaking, it simply not working and sql errors. We want to keep this method as simple as possible without resorting to plugins so we'll use the following method: (Ref)
Open up the following files in your Wordpress theme:
- index.php (/wp-content/themes/your-theme-name/index.php)
- archive.php (/wp-content/themes/your-theme-name/archive.php)
- search.php (/wp-content/themes/your-theme-name/search.php)
In each of the files, where you see the following code:
<div class="post">...
add this line just above it:
<?php if (in_category('{YOUR cat_ID}')) continue; ?>
so now our code in those 3 files will look like this:
<?php if (in_category('{YOUR cat_ID}')) continue; ?>
<div class="post">... etc.
We are telling Wordpress not to display any posts from our Newsletter category. Whilst this technique is the least problematic, there is something that's important to understand. Quoted from the Wordpress documentation:
"Please note that even though the post is not being displayed it is still being counted by WordPress as having been shown -- this means that if you have WordPress set to show at most seven posts and that two of the last seven are from Category 3 then you will only display five posts on your main page. If this is a problem for you, there is more complicated hack you can employ described in the Layout and Design FAQ or you can use query_posts if you only need to exclude one category from the loop." (Ref)
The above is also true of search results. However if you are sending out a newsletter about once a month, it shouldn't be a real problem.
We also don't want any posts in the 'Newsletter' category to show up in navigation when viewing single posts / permalinks. Open up single.php (/wp-content/themes/your-theme-name/single.php) and search.php (/wp-content/themes/your-theme-name/search.php) and change the following:
<div class="navigation">
<div class="alignleft"><?php previous_post_link('« %link') ?></div>
<div class="alignright"><?php next_post_link('%link »') ?></div>
</div>
to:
<div class="navigation">
<div class="alignleft"><?php previous_post_link('%link', '%title', FALSE, '{YOUR cat_ID}') ?></div>
<div class="alignright"><?php next_post_link('%link', '%title', FALSE, '{YOUR cat_ID}') ?></div>
</div>
(Ref 1, 2)
Step 4 - Hiding 'Newsletter' in our RSS
Now that we have our category set up we can move on to the RSS feed that will power our newsletter.
Just as we didn't want the 'Newsletter' category to show in our sidebar or in our posts, we also don't want it showing up in our website's regular RSS feed.
The url for your Wordpress site's RSS feed should be something like http://yourwpsite.com/?feed=rss2. To exclude our 'Newsletter' category we 'add &cat=-{Your cat_ID}' to the end so it now reads http://yourwpsite.com/?feed=rss2&cat=-{Your cat_ID}.
In the file header.php (/wp-content/themes/your-theme-name/header.php), you should see a line that reads:
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
change this to:
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="http://yourwpsite.com/?feed=rss2&cat=-{Your cat_ID}" />
If you already have your main Wordpress feed running through FeedBurner, you'll need to sign in to FeedBurner, go to 'My Feeds', choose your feed and go to 'Edit feed details...' and change the 'Original feed' option.
Step 5 - Creating our RSS feed!
Now we create an RSS feed for just the 'Newsletter' category by using the URL http://yourwpsite.com/?feed=rss2&cat={Your cat_ID} - this is now your newsletter's RSS feed url.
That was easy!
Step 6 - Burning the 'Newsletter' feed
Now we have an RSS feed for our newsletter, sign in to FeedBurner and enter your newsletter's RSS feed url into the 'Start FeedBurning now' form:
or 'Burn a feed right this instant':
Click 'Next »'.
Give your newsletter a name and new url:
Click on 'Activate Feed'. You can then add extra bits via 'Next Step' if you wish or 'Skip directly to feed management'.
Step 7 - Turning the Feed into an Email Newsletter
Almost done! Once FeedBurner tells you that your feed is ready, click on 'Publicize' up the top:
then choose 'Email Subscriptions' on the left:
Leave the default settings and click 'Activate'.
You will now be given the 'Subscription Form Code' or 'Subscription Link Code' which allows your site visitors to sign up for the newsletter. Decide if you'd like a form or a link, copy the appropriate code and paste it into your site. The sidebar might be a good place to paste it for now. You could also add a 'Sign up for the newsletter' title above the code just to make it clear.
The number of newsletter subscribers' and their email addresses can be viewed in your FeedBurner account, under Publicize > Email Subscription. You cannot sign people up on their behalf, which is a good thing. Users must click on a verification link sent to their email address before they are signed up.
Step 8 - Sending out a newsletter
Now all the fiddly stuff is done, sending out a newsletter is as simple as publishing a post to the 'Newsletter' category.
What happens is that when you post to the 'Newsletter' category, the RSS feed we created for that category updates. This alerts the FeedBurner email service which grabs your update and emails it out to your list subscribers.
When you publish a 'newsletter' post, the email is not sent out straight away, but at the end of that day. This can allow you to edit or make adjustments to your mail-out before it is sent.
Here is how the newsletter looks in Gmail:
Note that in this test scenario my newsletter is called 'WP Dev', that's just the title of the Wordpress blog I set up to test this, the newsletter will pick up the title of your Wordpress site. It says 'Newsletter' as that is what I called my newsletter category.
I hope this tutorial eases any newsletter pains you may be having. Enjoy!
Final Notes
- You can test this all out by signing up and posting a newsletter to yourself before putting the sign up form on your site.
- Be sure that your RSS feed is set to show 'Full Text' under Settings > Reading in the Wordpress admin area:
Otherwise people will just receive a snippet of your newsletter instead of the full thing.
- You can follow this method for multiple categories, often by seperating category IDs with commas. I haven't gone into this during this tutorial but you can find out more by clicking the 'Ref' links you see in this article.
- By their nature, RSS feeds are very adaptable. If you come up with an interesting take or build on this technique please leave a comment about it.
- If you wanted to go a newsletter crazy, you could go as far as setting up a Wordpress blog just for newsletters, but that's another story.
- As mentioned at the start, this was tested on Wordpress 2.5.1 using the default theme. Your code may differ somewhat depending on the theme you are using but the principles remain the same.
- It seemed that the trickiest part in creating this tutorial was getting Wordpress so successfully ignore a category without it having a knock-on effect or breaking other parts of the site. There is a plug-in called Ultimate Category Excluder that might be worth a look but I have not tried or tested it.
User Comments
( ADD YOURS )D. Carreira May 17th
Great tutorial! Thanks.
David Carreira
BroOf May 17th
Very nice! Very helpfull!
Ukrnet May 17th
I like it very much! Cool!
Collis May 17th
Great work Paul, a really simple but effective idea. I’m going to use this for sure!!
Simon May 17th
An alternative to if(in_category()) would be to alter the query before starting The Loop:
query_posts(’showposts=10&offset=0&cat=-42′);
This should be placed above “if (have_posts())”. This won’t mess with the number of displayed posts. The downside of this method however is that is screws up pagination (/page/x urls), but since you have both a showposts and offset variable available in query_posts(), it’s possible to build your own pagination function.
But that aside, there actually are plugins available to hide categories from both site and feeds.
Adam May 17th
great tutorial!….lil mistake in the intro to it though on the main page “Of course *keeping keeping* up a newsletter “
Ben Jacob May 17th
Is there any way to send HTML email newsletters by our own ?
giackop May 17th
uou that’s useful!!
Ben Griffiths May 17th
Cool tutorial, thanks!
Jacob Gube May 17th
Paul,
Excellent tutorial. I think the main thing to keep in mind in this post is the concept and methodology.
You can tweak it and use
query_postsor the one outlined by Paul, what’s important is the method of using Wordpress as a newsletter manager, which to be honest, I haven’t really thought of before.Razvan May 17th
Good stuff, will probably use it on a few of my wp powered sites.
roger May 17th
and if you want to keep it a secret/private/members don’t forget to block the spiders with robots.txt, i think
Ibrahim Cesar May 17th
Or just make a Wordpress instalation in a place like example.com/newsletter, do the RSS, and offer the code in you blog. A lot more simple.
Lamin Barrow May 17th
This is the first tutorial on this site with some server side code in it. I am hoping to see more of this.
AndrU May 17th
Superb!, thanks for the tutorial.
Cheerz!,
Tammy Lenski May 17th
Yowza! This is terrific. I’ve wanted a way to use Wordpress like this but am not familiar enough with PHP to be able to figure this out on my own. Thank you!
Does anyone know the names of the plugins Simon refers to and if they’re any good?
Nate May 17th
Nice tutorial. Thanks Collis
TYPO: keeping keeping in the opening paragraph in italicized.
Danny May 17th
That’s great, never knew it could be that easy!
Andrew May 17th
Very useful tip, thanks. I’ve been meaning to look into how to add a newsletter to my wordpress site, this seems like a nice option.
http://www.myinkblog.com
Joefrey Mahusay May 17th
Great tut Paul. Thanks for sharing.
Hamilton May 17th
This a great tutorial for communicating with your users. Thanks!
Here’s a project that lets your users talk to each other:
http://copaseticflow.blogspot.com/2008/05/laborator-collaboration-tools-for.html
Collis Ta'eed May 17th
Thanks guys, fixed those two typos!!
Gotta get some copy editing happening!
Nico May 17th
Very useful! Thanks!
Kriesi May 18th
Very interesting way to use the RSS Feed =)
Thanks for this useful information
Louie May 18th
This is awesome. Very useful specially on me because I’m using Wordpress. Thanks guys
Aminur Rahman [aka Tom R] May 18th
this is useful thanks
Serpentarius May 19th
Great Tutorial! thanx…
Tom May 19th
Good solution for managing a Newsletter.
Maybe not the best, but it works.
frank May 19th
Fantastic tutorial. You guys rock.
klou May 19th
Thanks , nice way for managing a newsletter.
But there’s a problem with validation at the rss and character ‘&’ .
Now what ?
Irregular Activity May 20th
If your talking about W3C validation then the & character has been devalued in XHTML and needs to be properly escaped, just change the & into & and it will validate.
Irregular Activity May 20th
Ok, thought that would happen change the & into & amp ; get rid of the spaces.
Tiziano Luccarelli May 21st
Great great tutorial! I am available to translate it in Italian if you want. Let me know.
Jermayn May 21st
I like the idea. Think a newsletter plugin could be easier for people with limited knowledge but this idea would be a bit easier to manage etc… Will definitely use
Niall Doherty May 22nd
The concept of this alone is phenomenal. I’d never thought of using FeedBurner as a newsletter delivery service like that. I’ll probably use the same trick on a CMS I’m building myself.
Excellent concept, great tutorial.
wpGuy May 23rd
Wow, excellent idea! Thanks for sharing!
Shane May 25th
A very interesting tutorial - gotta say I’d been looking how to do something like this. Thanks for posting.
Dave Wilkinson May 27th
Great idea. In fact, I was so impressed that I decided to build it on my own site. And it works! Thanks guys.
Chris B May 27th
Awesome Tut!!
Thanks for the great new site!
Chris B May 28th
awesome tut!!
thanks!
Mark Abucayon May 28th
Thanks for sharing this one. I really like it a lot.
Jbcarey May 29th
another great tutorial! love it!
One8edegree June 1st
What if the side bars are dynamic ? i cant add the ID to the catagory list ..can you help?
nemetral June 4th
Nice idea and simple code.
Great!
mm0704 June 4th
where do we create step 5:
Step 5 - Creating our RSS feed!
Now we create an RSS feed for just the ‘Newsletter’ category by using the URL http://yourwpsite.com/?feed=rss2&cat={Your cat_ID} - this is now your newsletter’s RSS feed url.
That was easy!
Thanks
Ara June 8th
Very very great tutorial…
I thought i should subscribe to your site now…
Thanks alot buddy!
Taylor Satula June 9th
I Should use this its really cool….
Jones June 23rd
creative thinking, love this idea.
J. Daniels July 1st
Would you have a tutorial soon on using feedburner to syndicate RSS not using blogs. For example, I have 137 html files and associated xml files that I want to syndicate. The files are a list of new titles received for a specific program at our institution. I used Feedburner for a few titles as a test, used the email option but nothing is being sent. I submitted this to Feedburner forums but no help offered. There is no actual Tech Support that I can find so I’m going round in circles. I find Feedurner documentation lacking in explanation on how to do things and troubleshooting has nothing as it pertains to me. I use custom programming and perl to find the titles for programs and then only update the xml file with today’s date if the list has new titles. I have been trying to get this to work for a week now (email option). I have email option enabled, the feeds are at feedburner, I have set the delivery time to 5-7 am. and I have GMT Saskatchewan time zone selected. The corresponding .xml files related to a new list for a program is automatically formatted to todays date and time of 06:00:00.
here is an example an update xml file. However, I must be doing something wrong in feedburner, but as mentioned, I can find no solution to the problem in their forums.
Associated Studies Titles Wascana Library
A listing of Associated Studies Titles in Wascana Library
http://www.siast.sk.ca/libraries
Tue, 1 Jul 2008 06:00:00 GMT
Associated Studies Titles Wascana Library
A listing of Associated Titles in Wascana Library
http://www.siast.sk.ca/libraries/FEEDS/wascana/assoc-studies.html
Tue, 1 Jul 2008 06:00:00 GMT
http://www.siast.sk.ca/libraries/FEEDS/wascana/assoc-studies.html
Raj Dash July 1st
J. Daniels: I can’t see your XML file, but my question is how is it created? The two URLS at the bottom of your email are in HTML document format, so if you’re using them, that’s the problem.
Generally speaking, when you have a site where the content is not automatically appended to an existing RSS/ Atom feed format file, you have two choices:
(1) Scrape your site using “screen” scraper software (too complicated) and generate the XML feed file (one time).
(2) Take your content pages and using an XML editor (or good HTML editor), manually create the initial XML feed file (one time).
Once that initial file has been created, in an appropriate feed format, you can “burn” it in Feedburner. But each time you create new content for the site, you will have to add it to the XML feed file.
Hope that helps.
David Lau September 4th
Well Done!
But can you tell me how to hide the posts from this category in the “Latest posts” at the sidebar?
Thanks!
David Lau September 4th
some code like this in the sidebar:
< ?php get_archives(’postbypost’, ‘10′, ‘custom’, ”, ”); ?>
graduit hentai world September 4th
hentai graduit one hentai graduit film
Windows Themes September 4th
i can’t wait to implement it on my wp sites. Thank you !
Chris September 17th
First let me say without this post I was sort of screwed for a client’s site making the newsletter easy to do from within the wordpress site itself. But I think I can help make this post A LOT shorter. I found this plugin:
http://wordpress.org/extend/plugins/advanced-category-excluder/
Which works great in simple clicking a checkmark to exclude the category anywhere from just the homepage, the archive, the rss feed (posts and comments), as well as site search. I have installed it on a 2.6.2 implementation and it is working great.
One note, it only seems work on the RSS2.0 feed and not the Atom or RSS feeds but I simple replaced those lines in my template to only us the RSS2.0 feed.
Thanks Again Paul!!!!
-Chris
DJ and Host
The Half Hour Comedy Hour
http://www.strangedesign.net
Bryan September 26th
Awesome!
Although, is there no way to format any html into the newsletters?
Mario September 30th
Muy buen dato, lo utilizaré para mi blog personal.
Muchas Gracias.
Aravind Jose T. October 4th
Thanks for this great, simple and well-documented tutorial.
Jason October 14th
Awesome tip! Thanks! Newsletters on the Cheap — for programmers
ninco October 15th
Magnífico tutorial.
Os dejo esta web, que me parece una herramienta excepcional para analizar links.
linkdiagnosis.com
Saludos
Blog Traffic 101 October 22nd
Superb post. Though I’ll have to print and go through the codes once again and try it out. Thx for sharing it.
TK October 25th
anyone know of a good means of collecting email address in wordpress? A form perhaps?
oceangray October 27th
very useful. thanks.
xiaop October 30th
very great! thanks
Add Your Comment
( GET A GRAVATAR )Your Name November 21st
Trackbacks