Thanks, RSS Readers

This post is secret; you can only find it via my RSS feeds (and places which syndicate them). It's okay to talk about it or link to it, though. Thanks for being part of RSS Club!

Fellow Automattician and RSS Club member Matthias Pfefferle wrote a post yesterday (in German, but automatic translation clearly gets the gist of it), observing that Kev Quirk‘s RSS feed contains

<p class="feed-email-link">
  Thanks for reading this post via RSS. RSS is great, and you're great for using it. ❤️
</p>
Kev’s RSS feed contains this message appended to the content of each post

Matthias went on to mention a snippet of WordPress code shared by Jeremy Herves, which he uses to achieve a similar thing but with a randomly-selected one of eight different messages of thanks:

/**
 * Display a nice welcoming message to folks reading posts via RSS.
 *
 * Kudos Kev Quirk for the idea!
 *
 * @param string $content The current post content.
 *
 * @return string
 */
function jeherve_welcome_rss_readers( $content ) {
        $welcome_messages = array(
                'Thanks for reading this post via RSS. RSS is great, and you’re great for using it. ♥️',
                'Congratulations on being an RSS reader! You are part of an elite group of people who know how to stay updated in style.',
                'Hey there, RSS reader! You’re one of a special few, choosing this old-school yet awesome way of staying informed. Kudos!',
                'You are a true RSS aficionado! While others are drowning in social media noise, you enjoy the simplicity and control of RSS. Congrats!',
                'RSS readers like you are the unsung heroes of the internet. Keep up the good work!',
                'You are a master of efficiency! By using RSS, you save time and avoid distractions. 👏',
                'RSS readers like you are the secret sauce of the internet. Keep rocking and staying informed!',
                'Hey there, RSS reader! You’re cool. Keep being awesome! 😎',
        );

        $welcome_message = $welcome_messages[ wp_rand( 0, count( $welcome_messages ) - 1 ) ];

        return sprintf(
                '%1$s<p>%2$s</p>',
                $content,
                $welcome_message
        );
}
add_filter( 'the_content_feed', 'jeherve_welcome_rss_readers' );
Jeremy’s solution.

Like Jeremy, I was inspired by Kev Quirk and have been appending a message onto my posts in RSS feeds for a while. My approach is a little different, though:

  1. Rather than a random number, I use the post ID modulus the number of random messages to choose which “random” message to select. This means that a given post has a consistent message, which minimises the risk that a post will be detected as having been “changed” by a feed reader, and it also helps to reduce “runs” of the same message after multiple posts in a row. I have a prime number of random messages to reduce the risk that patterns in my posting (e.g. a series of posts, without drafts, each with exactly one image, like my recent and ongoing Bleptember series) end up introducing a predictable pattern to the messages.
  2. I only use the random message if a specific one is not provided via postmeta. I’ve got a metadata field in my editing interface which, if filled, overrides the random message. This lets me put a specific or targetted message in, usually/especially if I’m talking specifically about RSS-related things!
WordPress postmeta field for "RSS Thanks".
When I author a post, sometimes I’ll override the message that appears for that post.

Here’s the code I use to inject the messages into my RSS feed:

function q23_rss_thanks_default( $post ) {
  $rss_thanks_messages = [
    "💖 RSS is fantastic, and so are you for using it. 🎆",
    "👏 Congratulations on being an RSS user. 🎉",
    "🥰 You're reading this post via the RSS feed. That makes you one of the best people on the Internet! 🏆",
    "📰 Using a feed reader is the best way to read my blog posts. How clever you are to know that! 🚀",
    "🌟 You're reading this post via the RSS feed, you star! 🌠",
    "🪄 Feeds are wonderful, and you're a wonderful person for using them. 🔮",
    "❤️‍🔥 You're reading this post via the RSS feed. You're on fire! 🔥",
    "🧨 RSS is dynamite! Thanks for subscribing to my blog. 💥",
    "🤘 You're subscribed to DanQ.me using the RSS feed. You rock! 🎸",
    "🕵️ Subscribing to DanQ.me's RSS feeds means that you'll get to see secret bonus posts not publicised on the main site. Clever you! 🧠",
    "🧡 I love RSS feeds. And I love you for using them. 💙",
    "🎗️ Using RSS feeds is a great way to keep up-to-date with my blog. Thanks for subscribing! 🤗",
    "🦸 You're my hero! (For using RSS to follow my blog.) 🥇",
  ];
  $post_id = intval( $post ? $post->ID : 0 );
  return $rss_thanks_messages[ $post_id % count( $rss_thanks_messages ) ];
}

function q23_rss_thanks( $content ) {
  global $post;
  $rss_thanks_message = get_post_meta( $post->ID , 'rss_thanks_message', true );
  $rss_thanks_message = empty( $rss_thanks_message ) ? q23_rss_thanks_default( $post ) : $rss_thanks_message;
  return $content . "<p style=\"margin-top: 0.5ch; padding-top: 0.5ch; border-top: 1px solid #ccc;\">$rss_thanks_message</p>";
}

add_action( 'the_content_feed', 'q23_rss_thanks' );
Note my use of intval( $post ? $post->ID : 0 ) to get the post ID, % count( $rss_thanks_messages ) to get it-modulus-the number of messages, and my get_post_meta and empty( ... ) check to allow post metadata to override it. Oh, and that code is CC0/public domain, if you want it.

Regardless of whether or not you love RSS as much as I do, thanks for reading my blog via RSS!

×

Reactions

No time to comment? Send an emoji with just one click!

1 comment

  1. Spencer Spencer says:

    Honestly, I find the random messages unnecessary. RSS is already clearly the best way to consume a blog; I don’t need an automated pat on the back for it. I do like the custom messages though, which fit with the “RSS club” concept of more content for RSS subscribers.

Reply here

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

Reply on your own site

Reply by email

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