WordPress Posts Without Titles in RSS feeds

Some RSS readers and aggregators will display things like “no title” or “untitled” for posts without a title in WordPress, which looks pretty awful. I’ve been playing around with post formats lately and things like links, quotes and images are fine without titles sometimes, but at other times they do require a title, so we can’t just “disable/hide” for all.

RSS Feed Items Without Titles

So I browsed around to see how others are doing it and of course looked at how Tumblr does it. When writing anything in Tumblr, it clearly tells you that the title is optional and most Tumblr themes are okay with that. I looked at how RSS feed entries without titles look and guess what! They’re displaying an excerpt. Not a 55 word excerpt but a shorter one.

So here’s a snippet for your functions.php file that wouldn’t let feed entries go without titles. It will look for an empty title and replace with a 15 word excerpt.

add_filter( 'the_title_rss', 'my_feed_title' );
public function my_feed_title( $title ) {
	if ( strlen( trim( $title ) ) < 1 ) {
		$words = preg_split( "/[nrt ]+/", get_the_excerpt(), 15, PREG_SPLIT_NO_EMPTY );
		array_pop( $words );
		$title = implode( ' ', $words ) . ' ...';
	return $title;

Hopefully a similar technique can be implemented for titles in the theme head section (or for SEO plugins that rewrite them), post titles in the commenting section, in popular posts lists and so on.

I do believe that titles are essential when it comes to articles, essays, tutorials and so on. But I also believe that things like asides, a link, a photo of your dog or a quote by Steve Jobs can look quite dirty (design-wise) with huge titles attached to them.

So who’s to blame? RSS aggregators for not being able to generate a title on their own? Or WordPress for not being able to provide one when absent? The RSS 2 specification says that all the elements in an item are optional, however “at least one of title or description must be present.”

I didn’t mind until I received a few comments from my friends and followers saying my RSS feed is broken. Also, things like Twitterfeed, Feedburner Socialize and so on stop working if they’re sharing titles and links only, so you get a lonely link in Twitter, doh!

14 thoughts on “WordPress Posts Without Titles in RSS feeds

    • Just noticed though that when using <code>the_title_rss</code> Yoast's WordPress SEO plugin fails to display the title at the end of each item if it's set to. Perhaps I should file a bug report and ask him to use <code>the_title_rss()</code> instead :) Meanwhile my previous solution works fine :)

    • I don't think it would have any impact on the speed. You see, the post has already been fetched so the only thing we're doing is string manipulation, besides, we're doing it on feeds which are often cached by things like Feedburner (you have to Troubleshootize – Resync to clear cache).

      Anyway, as Daniel mentioned, a title would be good for SEO, but who needs SEO on posts like this one? It's not like Google's gonna drive crazy traffic to that three-line post if it had an <code>h1</code> title, right? :)

      Thanks for your comment!

    • Code looks clean, well done, but I really don't see how this can be faster than filtering on the go. Have you benchmarked the two? Even if there is a microsecond difference, any caching plugin will get rid of it.

      However, I don't really like the idea of creating a title when one has not been created. Again, compare that to Tumblr :) And also, what happens when the post content changes at some point how do you know when you need to regenerate the title or when one has been supplied by the user? ;)


    • I think it is faster because it has to be done just once. Even if the inner logic would take ten times longer it would still be faster than generating all missing titles of a feed each time it is rebuild.

      When the post content changes it is up to the author to take care for the title. I would need a hidden post meta to catch those cases – too much overhead.

      Creating a regular title doesn’t hurt in any way, I guess. Those who don’t like it will use your plugin rather than mine. :)

    • You have a good point there Thomas, but I would benchmark anyway. Maybe I'm crazy talking but what if transmitting X bytes from MySQL to PHP takes Y amount of seconds which could be spared by transmitting less data (no title equals less data.) So if generating a title on the fly (Z seconds) from the excerpt takes less than Y seconds then it's faster :)

      However, I don't think that Y and Z will ever be anywhere close to a bottleneck, even with huge datasets, so you're right, both ways are okay :)

  1. I've been meaning to implement something along the lines of Thomas' suggestion and to simply not display the title for post formats where they don't make sense.

    Otherwise you just end up with this bunch of posts with '(no title)' in the WP backend as well as in the RSS feed, which makes it quite hard to find specific ones.

    I guess an alternative would be to keep the post title empty and use custom columns with an excerpt for the posts admin screen instead.
    What's your thoughts on that?

Comments are closed.