Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add Post Kinds for Wordpress kinds as a prefix to titles in RSS.
// Make titles in RSS feed be prefixed by the Kind of the post.
function add_kind_to_rss_post_title(){
$kinds = wp_get_post_terms( get_the_ID(), 'kind' );
if( ! isset( $kinds ) || empty( $kinds ) ) return get_the_title(); // sanity-check.
$kind = $kinds[0]->name;
$title = get_the_title();
return trim( "[{$kind}] {$title}" );
add_filter( 'the_title_rss', 'add_kind_to_rss_post_title', 4 ); // priority 4 to ensure it happens BEFORE default escaping filters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment