I've been using an added function to load a modified rss template. Works fine, but now I need to add a custom template for a CPT.
I have code for each,which works ok, but can't be used together because one over-rides the other.
I don't know enough php to modify.
Here's the code I'm using...
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', function() {
if ( $rss_template = locate_template( '/feeds/notes-feed.php' ) )
load_template( $rss_template );
else
do_feed_rss2(); // Call default function
}, 10, 1 );
and
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'item_feed_rss2', 10, 1 );
function item_feed_rss2() {
$rss_template = get_template_directory() . '/feeds/item-feed.php';
if( get_query_var( 'post_type' ) == 'item' and file_exists( $rss_template ) )
load_template( $rss_template );
else
do_feed_rss2(); // Call default function
Not knowing enough, I'm wondering if I can use this...
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'item_feed_rss2', 10, 1 );
function item_feed_rss2() {
$rss_template = get_template_directory() . '/feeds/item-feed.php';
$rss_template_notes = get_template_directory() . '/feeds/notes-feed.php';
if( get_query_var( 'post_type' ) == 'item' and file_exists( $rss_template ) )
load_template( $rss_template );
elseif( get_query_var( 'post' ) and file_exists( $rss_template_notes ) )
load_template( $rss_template_notes );
else
do_feed_rss2(); // Call default function