Prepend a note in your RSS feed’s content, if said post belongs to a certain category.

This is a follow up to the post that added a convenience comment link.

This time, we’re adding a small note if a post belongs to a category of our choice.

add_filter( "the_content_feed",  function ( $content ) {
	$categories = get_the_category();
	if ( !empty( $categories ) ) {
		foreach ( $categories as $category ) {
			if ( $category->slug == "fastmail" ) {
					$new_content = "<p>Shameless: here's my Fastmail referral link in case you want to support me that way.</p>" . $content;
			}
		}
	}

	if ( empty( $new_content ) ) {
		$new_content = $content;
	}
	
	$new_content .= "<p><a href=\"mailto:" . get_the_author_meta('user_email') . "?subject=Comment on '" . get_the_title() . "'&body=Post link: " . get_permalink() . "\">Comment via email</a>.</p>";
	
	return $new_content;
} );

I’m no PHP or WordPress wizard, so this is essentially a note to myself. The code too may be very garden variety, but that’s okay.

0

Comment via email.