WordPress

Changing your WordPress RSS feed titles

March 6th, 2009    8 Comments

In my last post I mentioned that I'd been tweaking the feeds from my WordPress blog. Here's the detail (in case I need to redo this next time I upgrade WordPress).

The problem

The feed for the ITauthor Podcast (which is just a feed for a WordPress category called "Podcast") was coming out as ITauthor >> Podcast. It annoyed me that the podcast showed up in iTunes with those two greater than signs, or double angle brackets, chevrons, whatever you want to call them. In fact, although it looks like two characters it's actually the double right angle quote character:
»   which is typically written in HTML using the character code » and in XML using the code »

My solution

The way I got rid of this may not be the easiest or best way. I search the WordPress Codex without finding out how to fix this, so in the end this is just the way I figured out how to do it. It may not be good. It may not be nice. It's certainly not pretty. All I'm saying is that it works for me.

So what I wanted to do was have a feed for my podcast category page that had the feed title "The ITauthor Podcast".

There were two tasks:

  1. Remove the angle quote completely in the cast of the feed for my "podcast" category page, but for other feeds change this character to a colon so that, for other categories, instead of "ITauthor >> Category", I'd have "ITauthor: Category".
  2. For the "podcast" category page, add "The" at the start of the feed title.


Here's what you do:

  1. Go into your wp-includes directory and take a backup copy of feed.php and feed-rss2.php.

    Now I've moved to Dreamhost, I have the luxury of an ssh connection and a command line, which makes this very quick and easy (provided you're happy working on the command line).
  2. Open the feed.php file (e.g. using vi or some other plain text editor).
  3. Change:

    function wp_title_rss($sep = '»') {
            echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
    }

    to:

    function wp_title_rss($sep = '»') {
         if (in_category('26')) {
              echo ' ' . trim( get_wp_title_rss('') );
         } elseif ( is_archive() | is_category() | is_tag() | is_date() ) {
              echo ': ' . trim( get_wp_title_rss('') );
         }
    }

    What this does is as follows.

    For category 26 (which happens to be the number of my podcast category), it gets the category title. The empty string for an argument means that it prepends a space followed by nothing (because I don’t want a separator character), followed by a space. The second space is added because the function expects a separator character in the middle. The trim function trims away the two spaces, but we add back a single space (that's the first thing that gets echoed) otherwise the result would be "ITauthorPodcast". 

    For all other categories, and various other types of pages we do exactly the same, but prepend a colon followed by a space, rather than just a space. This gives us "ITauthor: Category".

    For anything else (e.g. the Home Page) this function does nothing, which results in a feed title of just "ITauthor".

  4. Save your changes to this file.
  5. Open feed-rss2.php.

    This is the file that creates the RSS2 feed (the default format for feeds). It's here that the category title (as generated by wp_title_rss() in the feed.php file) is appended to the blog title. So it's here we can prepend "The " to give us "The ITauthor Podcast.
  6. Insert an if clause into the part of the script that prints the title, so that if this is the feed for the podcast category (ID 26 on my system) it adds "The " in front of the title generated by bloginfo_rss('name') and wp_title_rss().
  7. Change:

    <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>

    to:

    <title><?php if (in_category('26')) echo 'The '; bloginfo_rss('name'); wp_title_rss(); ?></title>

  8. Save the file.

Comments

  1. User Gravatar Tom Johnson said:

    March 8th, 2009 at 1:48 am (#)

    I've always found code snippets challenging in posts. Thanks for posting this.

  2. User Gravatar Ron said:

    May 14th, 2009 at 5:09 pm (#)

    I needed to do this exact thing and your blog post really helped. I did find a method of doing it that doesn't require hacking the feed.php file, so the change doesn't get blown away every upgrade. And it also handles other RSS data besides the title, like URL and description.

    You can find it all in this post http://www.reactuate.com/2009/05/14/custom-rss-feed-for-a-podcast-category/

  3. User Gravatar Alistair said:

    May 16th, 2009 at 10:16 am (#)

    Ron

    That's great. I've never tried writing a WordPress plugin so I was fascinated to see that it looks like it's not that hard to do. Thanks for the comment.

  4. User Gravatar Alistair said:

    June 28th, 2009 at 7:36 pm (#)

    I just realised that my feeds had switched back to "ITauthor >> Category" and eventually realised (as Ron commented above) that I'd done an upgrade, so this change had been blown away. It's a simple enough fix but annoying when WordPress upgrade come thick and fast as they have been doing recently - and especially now when it's so easy just to click-upgrade your WordPress installation.

  5. User Gravatar Joshua Hughes said:

    July 25th, 2009 at 2:47 am (#)

    Thanks for the blog post - both of these were helpful to finding a solution to a similar problem.
    However!  You can also install a wordpress addon called 'HeadSpace' (which I highly recommend for changing page descriptions, titles, meta keywords, etc).  Over at: http://urbangiraffe.com/plugins/headspace2/
    Under settings > Headspace click on Page Modules, then drag-and-drop the RSS Name module from disabled to advanced.
    Then click on Page Settings, then click on 'Global Settings', then click on 'advanced'.  I changed the name to ": Proven Solutions for Maximum Profits" and after the feed.php code is done with it, it looks like "The BizCoach: Proven Solutions for Maximum Profits".
    Cheers!
    -Joshua Hughes
    -Database & Software Development
    -Solid Technology, Inc.
     

  6. User Gravatar Alistair said:

    August 14th, 2009 at 7:07 pm (#)

    Hey, thanks for the tip Joshua - that sounds like a really useful plugin. I'll check it out.

  7. User Gravatar rxs said:

    December 31st, 2009 at 8:38 pm (#)

    i've also found that trick, but i forgot about "echo". Thanks for post.
    And Happy New Year.

  8. User Gravatar itauthor said:

    January 11th, 2010 at 3:06 pm (#)

    Glad you found it useful.
    Happy New Year!

Leave a comment

 

Is WordPress the Venice of blogging software?

March 4th, 2009    1 Comment

wordpress-logo

All I wanted to do was change the title of one of the RSS feeds for this blog. Sounds simple enough and, to be honest it wasn’t rocket science, but it did involve digging around among the foundations of my WordPress blog. And this made me think: WordPress is a bit like Venice. What you see (gliding towards the Lido on a water taxi or arriving at the home page of a WordPress blog) is usually attractive. There are things that are not so great (crumbling masonry or a cumbersome list of categories in a side panel), but on the whole it’s a good experience.

However, WordPress, like Venice, is not built on strong foundations. It’s built on the software version of rotting wood.

WordPress is a great example of a software application that has grown organically and has ended up one great big mess. Granted it’s a mess that people (millions of them) manage to do wonderful things with. But if you sat down to design a highly configurable, mass market blogging application you would not build it like WordPress. For starters (sorry PHP lovers out there), you would not use PHP. WordPress’s collection of PHP on PHP on PHP, distributed through a collection of files that is only loosely architected (I’m trying to be kind here), is the equivalent of Venice’s wooden posts driven into the mud of a lagoon, long, long ago. It seemed like a good way to build a town at the time. It made perfect sense back then. But the years went by and Venice grew: outwards and upwards. And down the ages the architects of Venice have wished they had something better to support their beautiful, lovingly designed constructions than lots and lots of rotting posts.

But to answer my own question: Is WordPress the Venice of blogging software? No, it’s not. And the reason it’s not is that, unlike WordPress, Venice will outlive us all. It’s too important and we love it too much. The posts are being replaced. Huge amounts of effort and money have gone into solving the problem of sinking buildings. Venice’s future is secure (except maybe for the effects of climate change – but that’s another story).

WordPress on the other hand, I believe, has trouble ahead. It’s massively popular right now. But because of the mess at its core, there’s an opportunity for someone to come along with something that provides everything WordPress does but is much easier to use, is easier to configure into a wider variety of looks and styles, and is easier to create plugins for. And because all your data is in a MySQL database, it wouldn’t be difficult to make it very easy to migrate blogs over to a new system.

At the moment WordPress is king of the hill. I, like millions of others, enjoy using it from day to day to write up our thoughts (like these) and inflict them on the world (or some small part of it). Mind you, I think the things I like most about posting to my WordPress blog are mostly features of Microsoft’s Live Writer application, which I use for writing posts, rather than features of WordPress itself.

So this king better watch out. I wouldn’t be at all surprised if, before too long, WordPress ends up the ruler of a small and crumbling city state whose days of influence are long behind it.

Marc-Olivier Maheu (http://www.flickr.com/people/marcomaheu/)

Leave a comment



Inserting a feed into your WordPress blog

March 4th, 2009    1 Comment

Now that RSS feeds are all over the place, and we have our own personal feeds provided for us on all sort of social network sites, it’s nice to be able to able to drop an RSS feed into your blog as a list.

Bill Rawlinson’s feedList plugin for WordPress allows you to do precisely that.

As a simple example of what it can do. Here’s my personal Writer River feed and my twitter feed grabbed and stuck together on a blog page:

http://www.itauthor.com/syndicated-posts/

Leave a comment



Site problems

October 28th, 2008    2 Comments

I went on holiday to Glen Esk for a week last week: no mobile phone reception, no Internet connection, just a week of walking the dog, listening to Radio 4 and reading books. Fantastic.

Little did I know that all that while my Web site was unreachable. It wasn't down as such, it was just that before going away I'd changed the home option in the wp_options table in phpMyAdmin to www.itauthor.com instead of www.itauthor.com. This didn't have any bad effect for me immediately - presumably because of some page caching going on either in WordPress or, more likely, my browser - but this change caused www.itauthor.com to be redirected to www.itauthor.com which is already redirected to www.itauthor.com, with the effect that nothing ever got resolved and a page was never displayed.

The itauthor.eu domain is just a temporary home until I rehome my .com domain. Anyway, sorry if you tried to visit the site last week. Mind you the number of emails I received about the site being unavailable (none) suggests that nobody minded too much (or noticed!) that the site took a holiday when I did.

 

Potentially similar posts

Leave a comment



WordPress upgrade plugin

October 12th, 2008

I just completed an upgrade of WordPress using the WordPress Automatic Upgrade plugin. I went from 2.2.3 to 2.6.2 without a hitch. It took me about 15 minutes.

The only thing I'd say is that I'm not sure I trust the backups the plugin makes. I had a look in the zip file and it didn't have a wp-content directory. So I'll continue to do manual backups, as follows:

1. Using FileZilla, download the whole WordPress directory (in my case this is the Web root directory, called web), with the exception of a couple of things that live within the wp-content directory:

  • advanced-cache.php
    This seems to be a link that FileZilla doesn't understand and treats like a directory, but drops the connection if you try to download it.
  • cache
    This directory won't reveal its contents and, again, the connection drops if you try to download it.

2. Backup your data using phpMyAdmin (see this tutorial, or this one) and save the SQL somewhere safe.

That said, I'm very impressed with this upgrade plugin. I'd been resisting upgrading because I was sure it would cause me pain. However, everything seems to be working, even PodPress.

The following video (there are 2 parts to it) is very slow-paced but it does go through the process very thoroughly. It also shows how to use the WordPress Database Backup plugin, which I'm just about to try out.

Leave a comment



^ back to top ^

Page 2 of 512345