Skip to content

Instantly share code, notes, and snippets.

@Dan-Q
Created January 1, 2026 18:04
Show Gist options
  • Select an option

  • Save Dan-Q/4d8ef5ca35119f4c1c8bcb5e06bee68d to your computer and use it in GitHub Desktop.

Select an option

Save Dan-Q/4d8ef5ca35119f4c1c8bcb5e06bee68d to your computer and use it in GitHub Desktop.
Code referenced by a ClassicPress/WordPress theme's functions.php to add RSS 'suffix messages', as used by DanQ.me.
<?php
/**
* Returns the DEFAULT "thanks" message for a post. This is determined (functionally-)randomly,
* using the ID of the post as the random seed.
*/
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 ) ];
}
/**
* Given post content, appends a "thanks for using RSS" message.
* If the post has a 'rss_thanks_message' custom variable set, use that (this allows a post to
* override the default message, which I sometimes use in posts specifically ABOUT RSS).
* Otherwise, uses `q23_rss_thanks_default` to get the default message for this post.
*/
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>";
}
/**
* When generating content for RSS feeds, consider adding a thanks message.
*/
add_action( 'the_content_feed', 'q23_rss_thanks' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment