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.
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:
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!
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.
Open up your theme's sidebar.php file (/wp-content/themes/your-theme-name/sidebar.php) and look for:
Change this to:
This will exclude our Newsletter category from showing up in the category list in our sidebar. (Ref.)
Open up the following files in your Wordpress theme:
add this line just above it:
so now our code in those 3 files will look like this:
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:
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:
to:
(Ref 1, 2)
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:
change this to:
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.
That was easy!
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'.
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.
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!
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.
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.
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:
1 | wp_list_categories('show_count=1&title_li=< h2 >Categories</ h2 >'); |
1 | wp_list_categories('show_count=1&exclude={YOUR cat_ID}&title_li=< h2 >Categories</ h2 >'); |
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)
1 | < div class = "post" >... |
1 | <? php if (in_category('{YOUR cat_ID}')) continue; ?> |
1 2 | <? php if (in_category('{YOUR cat_ID}')) continue; ?>< br > < div class = "post" >... etc. |
"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:
1 | < div class = "navigation" >< br > < div class = "alignleft" ><? php previous_post_link('« %link') ?></ div >< br > < div class = "alignright" ><? php next_post_link('%link »') ?></ div >< br > </ div > |
1 | < div class = "navigation" >< br > < div class = "alignleft" ><? php previous_post_link('%link', '%title', FALSE, '{YOUR cat_ID}') ?></ div >< br > < div class = "alignright" ><? php next_post_link('%link', '%title', FALSE, '{YOUR cat_ID}') ?></ div >< br > </ div > |
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:
1 | < link rel = "alternate" type = "application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<? php bloginfo('rss2_url'); ?>" /> |
1 | < link rel = "alternate" type = "application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="http://yourwpsite.com/?feed=rss2&cat=-{Your cat_ID}" /> |
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.
No comments:
Post a Comment