{"id":16809,"date":"2020-03-01T11:43:32","date_gmt":"2020-03-01T11:43:32","guid":{"rendered":"https:\/\/danq.me\/?p=16809"},"modified":"2020-03-01T11:58:45","modified_gmt":"2020-03-01T11:58:45","slug":"post-kinds-rss","status":"publish","type":"post","link":"https:\/\/danq.me\/2020\/03\/01\/post-kinds-rss\/","title":{"rendered":"Identifying Post Kinds in WordPress RSS Feeds"},"content":{"rendered":"<p>I use the <a href=\"https:\/\/wordpress.org\/plugins\/indieweb-post-kinds\/\">Post Kinds plugin<\/a> to streamline the management of the different types of posts I make on my blog, based on the <a href=\"https:\/\/indieweb.org\/posts#Types_of_Posts\">IndieWeb post types list<\/a>: <a href=\"https:\/\/danq.me\/kind\/article\/\">articles<\/a>, like this one, are &ldquo;conventional&rdquo; blog posts, but I also publish <a href=\"https:\/\/danq.me\/kind\/note\/\">notes<\/a> (which are analogous to &ldquo;tweets&rdquo;), <a href=\"https:\/\/danq.me\/kind\/repost\/\">reposts<\/a> (&ldquo;shares&rdquo; of things I&rsquo;ve found online, sometimes with commentary), <a href=\"https:\/\/danq.me\/kind\/checkin\/\">checkins<\/a> (mostly chronicling <a href=\"https:\/\/danq.me\/geo\/\">my geocaching\/geohashing<\/a>), and others: I&rsquo;ve extended Post Kinds to facilitate <a href=\"https:\/\/danq.me\/kind\/comic\/\">comics<\/a> and <a href=\"https:\/\/danq.me\/kind\/review\/\">reviews<\/a>, for example.<\/p><p>But for people who subscribe (either directly or <a href=\"https:\/\/danq.me\/2019\/10\/01\/email\/\">indirectly<\/a>) to <em>everything<\/em> I post, I imagine it must be a little frustrating to sometimes be unable to identify the <em>type<\/em> of a post before clicking-through. So I&rsquo;ve added the following code, which I&rsquo;m sharing here <a href=\"https:\/\/gist.github.com\/Dan-Q\/87027e17456d4102c7c78290023322cd\">and on GitHub<\/a> in case it&rsquo;s of any use to anybody else, to my theme&rsquo;s <code>functions.php<\/code>:<\/p><div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/ Make titles in RSS feed be prefixed by the Kind of the post.<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">function<\/span> <span style=\"color: #0066bb; font-weight: bold;\">add_kind_to_rss_post_title<\/span>(){\r\n\t<span style=\"color: #996633;\">$kinds<\/span> <span style=\"color: #333333;\">=<\/span> wp_get_post_terms( get_the_ID(), <span style=\"background-color: #fff0f0;\">'kind'<\/span> );\r\n\t<span style=\"color: #008800; font-weight: bold;\">if<\/span>( <span style=\"color: #333333;\">!<\/span> <span style=\"color: #007020;\">isset<\/span>( <span style=\"color: #996633;\">$kinds<\/span> ) <span style=\"color: #333333;\">||<\/span> <span style=\"color: #008800; font-weight: bold;\">empty<\/span>( <span style=\"color: #996633;\">$kinds<\/span> ) ) <span style=\"color: #008800; font-weight: bold;\">return<\/span> get_the_title(); <span style=\"color: #888888;\">\/\/ sanity-check.<\/span>\r\n\t<span style=\"color: #996633;\">$kind<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #996633;\">$kinds<\/span>[<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>]<span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">name<\/span>;\r\n\t<span style=\"color: #996633;\">$title<\/span> <span style=\"color: #333333;\">=<\/span> get_the_title();\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> trim( <span style=\"background-color: #fff0f0;\">\"[<\/span><span style=\"background-color: #eeeeee;\">{<\/span><span style=\"color: #996633;\">$kind<\/span><span style=\"background-color: #eeeeee;\">}<\/span><span style=\"background-color: #fff0f0;\">] <\/span><span style=\"background-color: #eeeeee;\">{<\/span><span style=\"color: #996633;\">$title<\/span><span style=\"background-color: #eeeeee;\">}<\/span><span style=\"background-color: #fff0f0;\">\"<\/span> );\r\n}\r\nadd_filter( <span style=\"background-color: #fff0f0;\">'the_title_rss'<\/span>, <span style=\"background-color: #fff0f0;\">'add_kind_to_rss_post_title'<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">4<\/span> ); <span style=\"color: #888888;\">\/\/ priority 4 to ensure it happens BEFORE default escaping filters.<\/span>\r\n<\/pre>\n<\/div><p>This decorates the titles of my posts, but only in my feeds, so it&rsquo;s easier for people to tell at-a-glance what&rsquo;s going on:<\/p><p id=\"image-16809-0\"><a href=\"#lightbox-p-image-16809-0\" title=\"Zoom in on image\" aria-haspopup=\"dialog\" role=\"button\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-16814 size-large\" src=\"https:\/\/danq.me\/wp-content\/uploads\/2020\/03\/post-kinds-rss-2-480x1024.png\" alt=\"Rendered RSS feed showing Post Kinds prefixes\" width=\"480\" height=\"1024\"><\/a><\/p><p>Down the line I might expand this so that it <em>doesn&rsquo;t<\/em> show if the subscriber is, for example, asking <em>only<\/em> for articles (e.g. via <a href=\"http:\/\/danq.me\/kind\/article\/feed\">this feed<\/a>); I&rsquo;m coming up with a huge list of things I&rsquo;d like to do <a href=\"https:\/\/danq.me\/2020\/02\/10\/rsvp-iwc-london-2020-yes\/\">at IndieWebCamp London<\/a>! But for now, this feels like a nice simple improvement to a plugin I love that helps it to fit my specific needs.<\/p><dialog id=\"lightbox-image-16809-0\" class=\"lightbox\"><p id=\"lightbox-p-image-16809-0\"><a href=\"https:\/\/danq.me\/wp-content\/uploads\/2020\/03\/post-kinds-rss-2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-16814 size-large\" src=\"https:\/\/danq.me\/wp-content\/uploads\/2020\/03\/post-kinds-rss-2.png\" alt=\"Rendered RSS feed showing Post Kinds prefixes\" width=\"480\" height=\"1024\"><\/a><\/p><a class=\"close\" href=\"#image-16809-0\" title=\"Close image\" role=\"button\">&times;<\/a><\/dialog>\n<div class=\"syndication-links\"><span class=\"relsyn\"><data class=\"u-syndication\" value=\"https:\/\/scatmania.livejournal.com\/226087.html\"><\/data> <data class=\"u-syndication\" value=\"https:\/\/twitter.com\/scatmandan\/status\/1234082071230001152\"><\/data> <data class=\"u-syndication\" value=\"https:\/\/www.facebook.com\/DanQBlog\/posts\/2596369157142651\"><\/data><\/span><\/div>","protected":false},"excerpt":{"rendered":"<p>Dan shares the code he&#8217;s written to improve Indieweb Post Kinds support in his RSS feeds.<\/p>\n","protected":false},"author":1,"featured_media":16814,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"mf2_syndication":["https:\/\/scatmania.livejournal.com\/226087.html","https:\/\/twitter.com\/scatmandan\/status\/1234082071230001152","https:\/\/www.facebook.com\/DanQBlog\/posts\/2596369157142651"],"webmentions_disabled_pings":false,"webmentions_disabled":false},"categories":[3],"tags":[355,931,351,469,281,107,914,906],"kind":false,"_links":{"self":[{"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/posts\/16809"}],"collection":[{"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/comments?post=16809"}],"version-history":[{"count":3,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/posts\/16809\/revisions"}],"predecessor-version":[{"id":16815,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/posts\/16809\/revisions\/16815"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/media\/16814"}],"wp:attachment":[{"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/media?parent=16809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/categories?post=16809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danq.me\/_q23j\/wp\/v2\/tags?post=16809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}