I Design + Develop + Support WordPress websites

Create a Newsletter in WordPress

Ever wanted to create a separate “newsletter” page for your site that’s segregated from your main blog? This tutorial will walk you through doing just that for your WordPress site.

This post comes to you courtesy of Angelique at AfMarCom.com who had me create this solution for her site.

Step 1: Create Your First Newsletter

This part will be easy for anyone who’s used wordpress for any length of time. Just create a post as you normally would by clicking the posts link along the left hand side of your admin panel and then select “Add New.”

Maybe you’ll write about some time sensitive topic you really want people to read now. Maybe you want to offer excerpts from your weeks posts. Or as Angelique chose to do maybe you want to pair highlighted posts from the week with special newsletter only content.

So you’ve written your newsletter, and you’re ready to push that pretty blue “Publish” button. Don’t do it just yet. Wait for the next step.

Step 2: Create a Newsletter Category

There are other ways to do this (such as in the categories control panel), but you may as well do it while you’re creating your post. Just look for the “Categories” box along the right site of “Add New Post” page. Click “+ Add New Category,” name your category something like “Newsletter,” and click “Add.” Make sure the category is checked before moving on.

Ok, now you can go ahead and publish your post.

Step 3: Exclude your Newsletter from your blog page

Here comes the “tricky” part. First we need to find out what the category ID number of your new category is. Click the posts link along the left side as you did when creating a post, but this time select the “Categories” link.

Now find the Newsletter category you just created and hover your mouse over the link. In your browser’s status bar (usually in the lower left) you’ll see the URL this link will take you to. It’ll look something like this http://pressmy.biz/wp-admin/categories.php?action=edit&cat_ID=5. That number at the end is your category ID. Write it down for the next step.

Next we’re going to add some code to your theme’s functions.php file. Open it in your favorite text editor and add this code:

function exclude_category($query) {
if ( $query->is_feed || $query->is_home ) {
$query->set('cat', '-1');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Before you go accusing me of being a php genius here’s where I found that code

You will need to make one little change to that code. See the part that says $query->set(‘cat’, ‘-1’);? Just change that number 1 to the category ID number you wrote down earlier.

Finish off this step by uploading functions.php to your server using your favorite FTP program. Check your blog page and make sure the post you just created isn’t showing up.

Step 4: “Create” your Newsletter Page

You may have noticed that “create” is in quotes up there. This is because we’re just going to use the archive system built into WordPress. First lets make sure your newsletter post is showing up on the category archive page.

The URL should be something like http://pressmy.biz/category/newsletter where “newsletter” is the name you gave your new category.

Some Thesis Only Display Options

Angelique uses a premium WordPress theme called Thesis, so to make her new newsletter page show up nicely I made a few changes to the theme which I’ve included here in case you use thesis too. If not you can ignore this step.

Unless you’ve already changed the thesis archive display options you’ll probably just see the title of each post in the category. If you like this then you can skip the rest of this step.

Customizing the look of your archives pages is one place that Thesis really shines. Just visit the “Thesis Options” panel and find “Archives” under “Display Options” along the right had column. You’ll find four options that should be pretty self-explanatory, but here’s a brief explanation:

  • Titles only: This is probably currently select. It will display only your post title as a link to the post
  • Everything’s a teaser!: Your archives pages will appear with a double column of post excerpt with a title, published date and read more link.
  • Same as your home page: Your archives will look just like your home page. Nothing more to be said here.
  • Post excerpts: This will look much like “Everything’s a teaser!” except each excerpt will take up the whole column

Just pick one and click the save button. Play around until you find the option you like.

Step 5: Add your Newsletter Page to Your Navigation Menu

Now that WordPress 3.0 is out you can add navigation menu items on any 3.0 safe theme super easy by visiting Appearance > Menus and adding the category to the menu.

Step 6 (optional): Remove “From the category archives” (thesis only)

Another “thesis only” step. Skip it if you don’t use thesis.

If you’re like me and you think the “From the category archives” text at the top of your Thesis Newsletter page shouldn’t be there, with a quick addition to your custom.css file we can fix that. Open Custom.css found in the custom folder of the main thesis folder and add the following code:

.cat_newsletter #archive_info p {
display:none;
}

Be sure to change “newsletter” in .cat_newsletter to the name of your category. If you would prefer to remove this text from all your archive pages simply remove the .cat_newsletter class from the above code

You’re Done!

There you have it. Now you have a newsletter page for your WordPress site where you can post special content, time sensitive posts, or summaries your blogging activity for the week or anything else.

What else can you think of to use a “newsletter” page for?

Another note

If you’d like to have multiple newsletters that don’t show up on the blog page, just replace

$query->set('cat', '-1');

with

$query->set('cat', '-1', '-2', '-3');

Notice, you’re just adding a comma and then adding new category IDs. Really simple!

Speak Your Mind

*