Identifying Post Kinds in WordPress RSS Feeds

I use the Post Kinds plugin to streamline the management of the different types of posts I make on my blog, based on the IndieWeb post types list: articles, like this one, are “conventional” blog posts, but I also publish notes (which are analogous to “tweets”), reposts (“shares” of things I’ve found online, sometimes with commentary), checkins (mostly chronicling my geocaching/geohashing), and others: I’ve extended Post Kinds to facilitate comics and reviews, for example.

But for people who subscribe (either directly or indirectly) to everything I post, I imagine it must be a little frustrating to sometimes be unable to identify the type of a post before clicking-through. So I’ve added the following code, which I’m sharing here and on GitHub in case it’s of any use to anybody else, to my theme’s functions.php:

// Make titles in RSS feed be prefixed by the Kind of the post.
function add_kind_to_rss_post_title(){
        $kinds = wp_get_post_terms( get_the_ID(), 'kind' );
        if( ! isset( $kinds ) || empty( $kinds ) ) return get_the_title(); // sanity-check.
        $kind = $kinds[0]->name;
        $title = get_the_title();
        return trim( "[{$kind}] {$title}" );
}
add_filter( 'the_title_rss', 'add_kind_to_rss_post_title', 4 ); // priority 4 to ensure it happens BEFORE default escaping filters.

This decorates the titles of my posts, but only in my feeds, so it’s easier for people to tell at-a-glance what’s going on:

Rendered RSS feed showing Post Kinds prefixes

Down the line I might expand this so that it doesn’t show if the subscriber is, for example, asking only for articles (e.g. via this feed); I’m coming up with a huge list of things I’d like to do at IndieWebCamp London! But for now, this feels like a nice simple improvement to a plugin I love that helps it to fit my specific needs.

×

5 comments

  1. I like the idea of adding the kind of post to the RSS feed to identify it, although not everyone will. I’ve opened an issue to remind myself to explore a version of it in future. Working on a major change to the plugin now.

    Read more →

  2. Alex Bowyer Alex Bowyer says:

    Hi Dan. This is a great idea. Thanks for sharing the post kinds plugin. I especially like the distinction between “Notes” and “Articles” – this might be just what I need to combine social posts and long form articles output into one place. I really like this structure of your blog, and am thinking of revamping mine to a similar sort of design/structure. Would you be willing to share the theme and list of plugins you use? Is it a custom built theme or an off the shelf one?

    1. Dan Q Dan Q says:

      Hi Alex!

      My theme (and most of my plugins) are custom-written, but I really should open-source more of it. If you’re developing an indieweb-friendly theme from scratch, you might learn a lot from e.g. IW Twenty Fifteen.

      I’ll write a proper blog post about “how my blog works” at some point, but the short version might look like this: the important plugins I’m using are:

      Classic Editor (some of my plugins, especially the ones I’ve written myself, aren’t Gutenberg-friendly yet).
      A handful of plugins to help manage my custom-PESOS (e.g. this one which imports my geocaching logs) integrations.
      IndieAuth for IndieAuth authentication, but IndieLogin is probably fine for most people.
      Post Kinds, for post types
      Webmention/Semantic-Linkbacks for webmention management
      Syndication Links to streamline backend admin of my POSSE publishing
      Some security-related plugins providing my backups, MFA, etc.

      Then my theme:

      (a) tweaks image/thumbnail sizes
      (b) adds extra post types (collection, comic, and review)
      (c) hides the front-end links shown by syndication-links (I manually show them in my theme templates)
      (d) removes WP’s own “feed links” from the <head> (I add these manually in order to publicise different URLS for different “post type” feeds)
      (e) provides shortcodes that I use to power my homepage (with its recent articles, recent “other stuff”, random old article-of-the-day, how-many-things of type etc.) and other pages (e.g. my under-development geo*stats page)
      (f) replaces most Gravatar links with an internal proxy (for caching and privacy)
      (g) selectively auto-approves webmentions (based on this code)
      (h) adds “kinds” to the RSS feeds, as per this post!
      (i) REMOVES a lot of things I don’t like; e.g. many plugins try to add their own front-end CSS and JS, which I rarely want, so I un-hook them all (for performance and privacy)
      (j) adds a service worker, app manifest etc.

      The whole thing then sits behind an Nginx reverse proxy which runs PageSpeed across most of the output and caches it (for performance). The net result is that you can visit danq.me with an ad-blocker on (which’ll be the subject of a future post!), and with third-party resources (JS, CSS, and images!) blocked, and virtually everything will still work as it should! No privacy-leaking/performance-degrading third-party nonsense here!

      If that’s an intimidating shopping list, don’t despair: it wasn’t built in a day! It represents many gradual iterative improvements, which is absolutely the way to run a personal blog IMHO. If you don’t already, check for a local Homebrew Website Club (or consider joining me at IWC London 2020 if you’re in that neck of the woods; these folks are great for inspiring you to “go further” with your personal web presence!

      Hope that helps! More in an actual blog post, someday!

  3. Aaron Davis Aaron Davis says:

    This is a really interesting idea. One of my itches has been to automate the insertion of emojis into the title of posts. This might help in making sense how I might be able to do it.

    Read more →

    1. Dan Q Dan Q says:

      If it’s for RSS purposes, definitely! If you want the emoji added to the title in general then you might look at the the_title filter, documented (with relevant example) here.

Reply here

Your email address will not be published. Required fields are marked *

Reply on your own site

Reply elsewhere

You can reply to this post on Facebook.

Reply by email

I'd love to hear what you think. Send an email to b16809@danq.me; be sure to let me know if you're happy for your comment to appear on the Web!