Theme Customization

How do I set up RSS Feeds on my WordPress website?

February 10th, 2010 | 5 Comments | Filed in Answers to Your Questions, Theme Customization

Q. How do I set up RSS Feeds and enable email subscription to feeds on my self-hosted WordPress website? Also, how do I promote that feed elsewhere (like on my LinkedIn account)?

By default, WordPress comes with various feeds (http://codex.wordpress.org/WordPress_Feeds). These different feeds are invoked via template tags in the WordPress theme header.php file. You can customize the feed a variety of ways, to include comments, for example, or feed just one category of your blog.

As long as your theme has a feed link on it, you can use the default WordPress feed. However, the default feed doesn’t give you statistical information about the number of subscribers to your feed without using a third-party plugin.

For RSS Feed subscriptions and tracking, many people redirect (aka “burn”) their default WordPress feeds using Google’s Feedburner (http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78483). Google Feedburner can track every possible subscriber. It will forward for your main posts feed and optionally, your main comments feed as well.

1) To get started, you’ll first need to “burn” your feed with Feedburner:

  1. Visit http://feedburner.com and log in to your Google account. (If you don’t have one, create one.)
  2. You’ll be prompted to “burn a feed right this instant.” Simply type the URL of your self-hosted WordPress site. Feedburner will automatically detect any feeds coming from the site based on your theme set up.
  3. Choose the feed you want to burn (usually the Posts feed).
  4. You’ll be given an option to give the feed a title and a name (see screenshot to above).
  5. Click the Next button.
  6. The URL for your feed displays. Be sure to make a note of this! We will use this address below to redirect the feeds to Feedburner using a WordPress plugin. (In my example to the right, my feed address is: http://feeds.feedburner.com/WPClass). This URL can be used other places as well, such as promoting your Feed on your LinkedIn account.
  7. You can then choose various stat options.
  8. If you want to allow people to subscribe to your feed via email, click the Optmize tab on the next Feedburner page and click Email Subscriptions and activate email subscriptions. You’ll be given some code that you can optionally use on your website if you want to have form field for people to enter their email addresses. Otherwise, the RSS link on your website will give them that option after they click the link.

2) Next, you need to tell WordPress to redirect your default feed to Feedburner:

Install a Feedburner plugin.

There are two to choose from that I like:

  • Feedburner smith: Feedburner plugin from Google. Has various options for burning your feed.
  • FD Feedburner: I prefer this simple feedburner plugin by Flagrant Disregard.

Enter your Feedburner address (step 6 above) in the plugin’s Settings (if you’re using the FD Feedburner plugin – see screenshot below).

3) Finally, you’ll want to use a cool RSS chicklet in your sidebar or header that links to your feed.

Most WordPress themes have an RSS icon built in. If yours doesn’t, you can add chicklet as follows:

  1. From your Feedburner.com account, click Publicize and click Chicklet Chooser. Some nice code will display that you can copy and paste into your template or a sidebar Text Widget. This is your run of the mill RSS chicklet.
  2. Alternately, you can design your own or download one of these: http://www.hongkiat.com/blog/really-cool-rss-feed-icons/
  3. If you decide to use your own chicklet, you can still use the code from Feedburner. You’ll simply change the link to the Feedburner image (<img src=”http://www.feedburner.com/fb/images/pub/feed-icon32x32.png” alt=”" style=”border:0″/>) to the location of your chicklet on your FTP server (such as http://mysite.com/images/my-cool-feed-icon.png).

Creating a Custom Single.php template

November 15th, 2009 | 9 Comments | Filed in Theme Customization

All posts on your WordPress site will be formatted using the single.php template. The single.php file is used when you click on the post title on the home page of the blog, and you see just the single post. This is efficient, but what if you have a Category of your website where you want the post page to look different, for example, a photo gallery that you want to take up the full page width with no sidebars? Here’s a bit of homework for you to make a custom single.php template for a particular Category:

  1. Put some content on your site if you don’t have any content. (Note: You can download andimport dummy content from http://wpcandy.com/articles/easier-theme-development-with-the-sample-post-collection.html. Simply, download and unzip the XML file and go to Tools > Import > WordPress and import this file into your site.)
  2. Take note of the Category ID # of the category for which you want to create a custom Single.php file. To get the ID #, mouse over the Category name in the Admin area and look in the browser footer.WordPress Category ID Number
  3. Make a back up copy of single.php, call this single-original.php.
  4. Open single.php in your HTML editor. Delete the contents of single.php and place the following code in it. Substitute the number 3 for the Category ID # you noted in step 2 above.
    <?php
    $post = $wp_query->post;
    if ( in_category('3') ) {
     include(TEMPLATEPATH . '/single2.php');
    } else {
     include(TEMPLATEPATH . '/single1.php');
    }
    ?>

    What this code says: If the post is in Category 3, then use the single2.php template to display the post. If the post is not in Category 3, then display the post using single1.php.

  5. Open single-original.php in your HTML editor and choose File > Save As and call this file single1.php. Choose File > Save As again and call this file single2.php. You should now have four files: single.php, single1.php, single2.php, and single-original.php (we won’t actually use single-original.php — this is for backup purposes only).
  6. Open single2.php in your HTML editor. Make whatever changes you want to make to this file to have it be unique to the category you specified above.
  7. Upload single.php, single1.php and single2.php as well as style.css (if you made changes to it) to your theme’s folder.
  8. Refresh your web page and click on one of the post titles in the category for which you are using single2.php.

Tags: , ,