Rewrite custom post type rss feed links

Put this in a plugin or functions.php:

function feed_rewrite( $wp_rewrite ) {

    $feed_rules = array(
        'feed/portfolio'    =>  'index.php?post_type=post&feed=rss2'
    );

    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'feed_rewrite' );

When you’ve done that, go to the permalinks page and resave to flush your old rules and regenerate them

Remember, when changing rewrite rules to use the monkeyman rewrite analyser tool plugin to check what rules are used for which URLs

Leave a Comment