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!

Snippet: A "Feed Only" Shortcode for WordPress

This might be valuable for banner ads, pitches to get people on to your website rather than simply reading stuff in their RSS feeds. You can address your RSS subscribers differently in each and every post, just by using this WordPress shortcode trick!

I’m not and ad-guy myself and I don’t care much if people read my feed or browse my website, as long as they’re reading my content. But I do know that some of you own websites that are driven by adverts and that’s good. Giving not full content but excerpts in your RSS feeds is one way to solve the problem, but that annoys most people including myself.

With this shortcode trick, you’ll be able to squeeze content into your posts that will be displayed in your feeds only. And by extending this example with a few extra lines, you’ll be able to do the same thing but the other way round — hide certain parts of your content in your RSS feed. Combining the two you might be able to give the full post content, where for instance the download link is visible to people on your website, while people reading your RSS feed get a different message, like “download available from this website”.

On to the code (for functions.php)!

function feedonly_shortcode( $atts, $content = null) {
	if (!is_feed()) return "";
	return $content;
}
add_shortcode('feedonly', 'feedonly_shortcode');

Once that is done, go ahead and create a new post, write some content, and then add:

... some content ...
[feedonly]Dear RSS readers, I'd really appreciate if you you came to <a href="http://yourwebsite.com">my website</a> and clicked a few banner ads ;)[/feedonly]

When you publish that you won’t see the text between the feedonly short codes on your website, but you will if you open up your RSS feed.

I believe this is a more intelligent and interactive way to speak to your RSS subscribers, rather than just sticking banners at the top/bottom of each feed entry, which don’t get clicked anyway ;) Hope this gets you closer to your feed readers, and please don’t annoy them too much ;)

Thank you for reading!

Quick Flickr Widget and the Flickr API Services

Hope you remember the Quick Flickr Widget plugin for WordPress. Well, since version 1.2 I’ve changed the way it works. Prior to 1.2, as Donncha suggested in his Flickr plugin, I used a public Flickr RSS feed to display the items, using WordPress’ RSS functions to move around the feed. Anyways I thought that I couldn’t take the plugin far enough, so I decided to use the Flickr API Services which is way more extended.

Still not sure about the consequences of sharing my Flickr API key. I’ve got a Flickr call for converting a Flickr screen name to a Flickr NSID which requires a valid API key. I thought that asking everyone to sign up for an API key would be a loss of plugin users so I provided my own key. Hope they don’t get me killed ;)

Now, to the user interface and experience. I’m not sure why, but some people are still confused about the new way and there are those, who cannot manage to find out their Flickr screen name (thinking that it’s their Flickr username or Yahoo ID). Anyways I hope to get this all sorted out and solved by 1.3 (maybe I should feed from Flickr by user e-mail?). Tiny bug in 1.2 was the inability to use a Flickr screen name with spaces. Thanks to Tung’s comments I sorted it all out by 1.2.1 – I had no idea people would use spaces in their screen names.

Now, for all the geeks out there. The Flickr API Explorer is the most fabulous thing that makes the Flickr API so easy to use. And the JSON Validator really helped me out there (I use JSON because I like it and also looking forward to adding some Javascript features to the plugin). So keep your comments and suggestions coming on the Quick Flickr Widget page.

Also, I’d like to recommend a book called Pro Web 2.0 Mashups which helped me out with Flickr API usage.

P.S. The Apps & Hats show launched on Friday 20th. The first episode is so cool. Girls with iPhones are so cute! Check them out: Apps & Hats – Your Quirky iPhone Application Review Show.

WordPress Junkies: Blogging via iPhone

I wrote about offline blogging with Windows Live Writer some time ago, and now I realized that it’s not that fun! Alright, I have two good news. The first one’s that I received approval for my second wordpress plugin (Related External Links) to be hosted at the official WordPress Plugin Directory. I commited the first beta a few minutes ago so go ahead and vote it up: Related External Links (thanks!).

The second news is… Y’know I’ve been dreaming about it since it was first announced. Yeah, I finally got myself an Apple iPhone!! Woot! It’s so sad that Moscow hasn’t got 3G internet yet (MTS announced it for the end of 2009) but I’ve got Wi-Fi at home and office plus EDGE everywhere else, so I guess I’ll survive. The first thing you definitely have to install on a brand new iPhone is TwitterFon. Get it for free from the iTunes Application Store (via iTunes on PC or App Store on your phone) and you’ll be tweeting 24/7, sending TweetPics along with your iPhone GPS coordinates. Jeez I’m so excited (BTW follow me!).

Anyways. Back to WordPress. I really appreciate that the WordPress team made this iPhone App. You can get it for free at the iTunes Application Store. It’s very user friendly and all the functionality you’d need is plugged into this little app. I’ve made some screenshots (thanks to @CMoz) to show you the whole process. Make sure you read the comments to each shot.

One more thing. If you’re into iPhone, you should definitely check out: Apps and Hats. It’s a brand new video blog about iPhone apps, which is launching 20th of March. Make sure you subscribe to their RSS feed and/or follow the Apps and Hats Twitter account. I think they’ll be using TwitterFeed to tweet their blog updates. Cheers!

FeedBurner and Google AdSense

All of you know what RSS is and why feeds should go through FeedBurner. Most of you also heard that Google has aquired FeedBurner so you shouldn’t be scared when FeedBurner will ask for your Google account details.

Anyways, I’ve been using FeedBurner for quite some time now and I definately don’t regret it. Some writers don’t like posting full articles to FeedBurner for many reasons. One of them is that authors aren’t getting any benefits from visitors reading their posts through RSS by-passing the adverts on their blogs. So here’s where AdSense comes in. You see, people don’t mind context-ads such as AdSense as long as they are relevant and some might be pretty helpful.

Getting an AdSense block into your feeds became very simple. All you need to do is link your FeedBurner account with a Google AdSense account (pick the ‘Monetize’ section in your FeedBurner profile). Afterwards just pick a channel, customize your advert and save. All feed entries will be posted with your lovely AdSense block ;)