Updates, Tips & Tricks

Updates as Released, Plus My Personal Collection Of WordPress Best Practices

Customize the WordPress RSS Feed For a Custom Post Type

07 April

Sometimes you want to customize the RSS Feed just for a custom post type, and leave the default alone. Here’s a snippet you can add to your functions.php that will allow you to do just that. You will need to add your custom-feed.php which you can base on one of WordPress’s default feed templates, found in wp-includes/feed*.php:

// Customize the Feeds
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'custom_feed', 10, 1 );
function custom_feed( $default ) {
    $feed_template = get_template_directory() . '/custom-feed.php';
    if( get_query_var( 'post_type' ) == 'customposttype' and file_exists( $feed_template ) ) {
        load_template( $feed_template );
    else {
        do_feed_rss2( $default ); // Call default function
No comments yet.

Leave a Reply