Skip to content

Instantly share code, notes, and snippets.

@jamesmthornton
Last active June 24, 2020 23:48
Show Gist options
  • Save jamesmthornton/fc0a39d7a24f996f842db7525a4d1b7a to your computer and use it in GitHub Desktop.
Save jamesmthornton/fc0a39d7a24f996f842db7525a4d1b7a to your computer and use it in GitHub Desktop.
Prepend a CTA to your RSS feed body/content or text to your subject line
<?php
// prepend a call to action to your email body by adding before your the_content()
function prepend_rss_cta($content) {
$cta = ' <p><i>Want to share or link to this post? It lives here: <a href="' . get_the_permalink( get_the_ID() ). '">' . get_the_title( get_the_ID() ) . '</a>.</i></p>';
$content = $cta . $content; // switch cta and content to append (not prepend) your CTA
return $content;
}
add_filter('the_content_feed', 'prepend_rss_cta');
// prepend some text to your subject line by adding it to before your post title
function prepend_rss_title_subject_line($title) {
$acronym = '[TEI] ';
$title = $acronym . $title;
return $title;
}
add_filter('the_title_rss', 'prepend_rss_title_subject_line');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment