I wanted a better way to showcase the really great stuff that I come across by other blog authors. I had been using my shared items feed from Google Reader, but I’m not the biggest fan of Google Reader and the options for display were very limited. (I’ve been trying Google Reader for nearly a month, but I think I prefer NewsFire more.) So, in this post, I am going to attempt to describe how I made a links feed, split WordPress to make that links feed appear in the right sidebar, changed my WordPress templates to exclude that links feed, changed my FeedBurner settings to reflect those alterations, used a new Facebook App to display my new combined links + site feed on my Facebook profile, and carried that all over to Twitter. (Phew!)
In English: I can now share links to quality content from other blogs on my site, and combine those links with my own feed on my Facebook and Twitter profiles. This serves multiple purposes: to add value for my readers, and to increase my reach both through my blog and other social media sites. I will start with an explanation of the whys, and then get into the code in a stepwise fashion.
Purpose, Goals and Reasons
Why would you want to republish a feed? I’ve heard the argument that publishing partial feeds or not publishing your feed encourages people to read it from your site and therefore increases your pageviews. In my experience, the opposite is true—syndicating your content gives you a greater reach, increases your subscribers and your pageviews, and creates new sources of traffic for your site that did not exist before.
My purpose in creating a links feed was to create another source of value for my readers, and to reward other authors creating good content with an additional source of traffic by tapping into my audience. I wanted this particular content—the links feed—to be separate from my regular content unless I was discussing it further, because simple links are not the kind of content my readers have come to expect from me.
As for Facebook and Twitter, I am still trying to use these platforms as a source of developing business relationships. I think that republishing my feed is a good way to increase my reach and continue on with my quest of making business contacts through social media.
If you are interested so far but I lose those of you who are business- but not technology-savy with the code section below, just remember—I’m for hire! ;-)
Creating a Links Feed
- Enter content using a new post, a new category, and custom fields.
To start, you need something to work with, so you’ll need to make a new post. I made a new category called "Links", with a slug of "links", and put my post in that. The post was relatively simple, following this format:
Post Title [link]
<p><a href=”url”>Title of Post being Linked To</a></p>
I added the designation of [link] to all the article titles for the benefit of the Facebook feed below.
To this post, I added custom fields in WordPress using the Custom Fields section in the bottom of the post editing page. For the key "link_desc":, I put a short description of the article; for the key "link_title", I put the name of the article I was linking to; and for the key "link_url", I put the url of the linked article.
- Create code to appear in sidebar.
- Burn the new feed.
- Hide the links feed from the rest of the site.
- Correct the original feed to exclude links.
- Create a new feed in Feedburner using your base site URL.
- Turn on tracking options for that feed in the Feedburner settings.
- Install Blog RSS Feed Reader into your Facebook profile.
- Configure the application with the special feed you created for this purpose.
- Using Custom Fields in WordPress
- The Loop in WordPress
- Advanced Category Excluder Plugin for those who don’t want to touch php.
Some people use the sidebar.php template that comes with WordPress and call it with get_sidebar(); I put my sidebars in my header file because I have more than one and call them with get_header(). Regardless of how you have your formatting set up, you will have to find the place where your sidebars appear in order to insert the following code:
<ul>
<li><a href="FEEDURL">Subscribe to the Links Feed</a></li>
<?php $my_query = new WP_Query(’category_id=CATID&showposts=NUMBEROFPOSTS’); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php if (in_category(’CATID’)) : ?>
<li><a href="<?php echo post_custom(’link_url’); ?>"><?php echo post_custom(’link_title’); ?></a><br />
<?php echo post_custom(’link_desc’); ?>
<?php if (post_custom(’link_addl’)==’yes’) : ?><br /><a href="<?php the_permalink() ?>">Additional Discussion</a><?php endif; ?></li>
<?php endif; ?>
<?php endwhile; ?>
</ul>
For this, you will need the category number (CATID in above code) for your links feed, which you can find in your WordPress admin in Manage -> Categories. (The ID is listed in the left column.) You will also need to know how many posts you want to display (NUMBEROFPOSTS) and the URL for your new feed (FEEDURL) which we will create and insert here in a later step.
In English, this code means to make a new query separate from the main Loop, use it to pull the posts from your links category, display them in a loop, and then close it all up.
My blog runs on the /topics/ slug for category archives, but yours may run on /category/ or whatever else you put in there. To find the feed for your links archive, click on one of your other archives and look at the url:
http://www.yoursite.com/category/business/ (for example)
and then change the category to links (or whatever you set it to be) and add the feed designation:
http://www.yoursite.com/category/links/feed/
This will be the URL that you will burn into a feed at FeedBurner. What you choose to call it, and what other options you turn on, are up to you.
Take the feed address you just created and it back into the sidebar code at the step before this. You will also need this URL for some of the instructions below.
To keep the links feed off the rest of the site, you will need to do some coding for exclusion. Also, if you have viewed the site since making the sidebar changes, you may notice some funny things going on. We will fix both of those right now.
You will need to alter your index file and archives file. To start, add this line directly under the get_header() command in archive.php and index.php for your current theme, which should make it the second line on each of these pages:
<?php rewind_posts(); ?>
This restarts the post counter which may have been changed by adding a secondary loop into your sidebar.
Next, for The Loop on the index page, take out this:
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
and add this line:
<?php if (is_home()) query_posts(’cat=-CATID’); while (have_posts()) : the_post(); ?>
where CATID is the links category number you identified above. (Make sure you leave the negative before the CATID!) This will tell WordPress to exclude any post on the front page which contains a post from the links feed.
To complete the archives page, the process is a bit more complicated. I wanted to be able to display the links as an archive if someone clicks on that Category name, but I didn’t want it to display in any other archive. To to this, I opened up archive.php and added the line
<?php if (in_category(’CATID’)) continue; ?>
within The Loop, after the line
<?php while (have_posts()) : the_post(); ?>
where CATID is the id number for your links category. This will make the archives skip the posts your links category even if you are viewing archives by tag.
Now, to add the ability to see the links category back in, in case someone wants to view the entire links feed on the web. After the loop but before the footer, add in these lines
<?php if ((is_category()) && (in_category(’CATID’))) : ?>
<?php endif; ?>
where CATID is the ID for your links category. Between these lines, add another copy of The Loop, including whatever was inside it. What this does is display an archive of the links category, on it’s own, if that option is chosen. Your final double loop will look like this:
<?php while (have_posts()) : the_post(); ?>
<?php if (in_category(’CATID’)) continue; ?>
Do stuff …
<?php endwhile; ?>
<?php if ((is_category()) && (in_category(’CATID’))) : ?>
<?php while (have_posts()) : the_post(); ?>
Do same stuff as above …
<?php endwhile; ?><?php endif; ?>
<?php endif; ?>
where CATID is the ID for your links category.
Upload your php files in the theme and try it out.
Note: If you have many links, this will greatly shorten the number of posts you see on your archive pages. You can compensate for this by increasing the number of posts per page in the WordPress Admin (Options -> Reading).
Now that the links have their own feed, I wanted to take them out of the master content feed for the site. To do this, I went to the original feed at Feedburner and selected "Edit Feed Details". I changed the original feed from a URL like
http://www.yoursite.come/feed/
to a URL that would exclude the links category,
http://www.yoursite.come/feed/?cat=-CATID
where CATID is the id of your links category. Note: it is important that you have the "-"before the category ID number, or it will only have posts from that category instead of excluding that category.
You may need to resync one or more of your feeds to get them up with current information during this process. This button is found on the Troubleshootize tab in FeedBurner.
And now, for Facebook …
I wanted to create a new feed just for use with Facebook. This lets me set Facebook-only parameters, and lets me track the usage of my feed from Facebook. To do this, I went to my account on Feedburner, and created a new feed using the base URL of my feed. (For WordPress, this base feed URL is http://www.yoursite.com/feed/) I gave it a special name, "Small Business Essentials for Facebook", and gave it a special feed name/URL, "http://feeds.feedburner.com/FacebookSBE".
I had originally been using my Google Feed in combination with Feedheads for Facebook, but that only works with Google Reader or NewsGator. To use my own feed, I found Blog RSS Feed Reader.
Bonus Points: Twitter!
I used TwitterFeed to get both the new links feed and my content feed into my Twitter updates. (The OpenID login process for TwitterFeed is kind of a pain though, sorry.) This uses my feed to generate relationships and traffic on Twitter as well.
In Summary
For those of you who are WordPress developers and found this organically through Google, I hope it helps! For those who aren’t developers, I hope this gave you some sense of the things that are possible by combining freely available software to work for you.
Questions?
If I left anything out here and this solution is not working for me, leave me a comment and I’ll see if I can work it out.




Mon, Jan 14, 2008
NHG News and Projects, Technology and Websites