Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

166 PART II • Designing and Developing WordPress Themes


The first one is the default; you’ll even find it in some themes, although that is a bad idea
because it requires permalinks to be set up and not all hosts support that. The following,
however, will always work but don’t look as pretty:

◾ http://mydomain.com/?feed=rss
◾ http://mydomain.com/?feed=rss2
◾ http://mydomain.com/?feed=rdf
◾ http://mydomain.com/?feed=atom

But there’s more! These are just for the main feeds, but there are actually feeds for just about
everything in WordPress. Author feeds, category feeds, and tag feeds all come in handy
sometimes. There’s even one for comments to a particular post. If you’ve got your permalinks
set up, this is how they are built:

◾ http://mydomain.com/author/USERNAME/feed
◾ http://mydomain.com/category/SLUG/feed
◾ http://mydomain.com/tag/SLUG/feed
◾ http://mydomain.com/POST-PERMALINK/comments/feed

So if my username is “superman” on http://tdh.me and I want to pull out all my posts via
RSS, this would work: http://tdh.me/author/superman/feed.

BUILD A CUSTOM FEED URL
Sometimes you may want your feed to exclude a category or consist of a couple of tags only,
perhaps. You can accomplish this by hacking the feed URL, which actually takes some
parameters. Then, if you want to, you can run that feed through a service such as FeedBurner
because the URLs tend to be pretty long and ugly.

For example, say you want to exclude the category with ID 47 from your custom feed. Then
the URL would look like this: http://mydomain.com/feed/?cat=-47.

That would output the full RSS feed but nothing in the category with ID 47. Notice the minus
sign in front of the ID; it works here just as it does in most other cases.

How about a feed for a search query? Just as simple: http://mydomain.com/
feed/?s=keyword1+keyword2.

Or maybe you want to just run category 39 and show the tag with the slug ninja. Do it like
this: http://mydomain.com/feed/?cat=39&tag=ninja.

Basically, you add parameters to the URL and work from there. The accepted parameters are
shown in Table 6-1.
Free download pdf