Custom RSS Feed
-
Hi there,
I need to use a custom RSS feed for this podcast that excludes certain episodes from the feed (based on tag). This threat from shanDB was somewhat helpful, but did solve the issue.
(1) I added the following to the function.php:
// Podcast - Exclude episodes w tag sneak-preview from RSS feed // Register the custom feed function podcast_no_sneak_preview_feed() { add_feed('podcast_no_sneak_preview', 'customRSSFunc'); } add_action('init', 'podcast_no_sneak_preview_feed'); // Function to render the custom feed content function customRSSFunc() { // Load the custom RSS feed template get_template_part('rss', 'podcast_no_sneak_preview'); } // Modify the custom feed query function exclude_sneak_preview_posts_from_custom_feed($query) { // Check if the query is for the custom feed if ( $query->is_feed() && $query->get('feed') === 'podcast_no_sneak_preview' ) { // Get the tag ID for the 'sneak-preview' tag $tag_id = 96; // Replace 96 with the actual tag ID of "sneak-preview" tag // Exclude posts with the 'sneak-preview' tag from the custom feed $query->set('tag__not_in', array($tag_id)); } } add_action('pre_get_posts', 'exclude_sneak_preview_posts_from_custom_feed'); // Callback function to connect custom feed with the RSS template file function custom_feed_template($templates) { if (get_query_var('feed') === 'podcast_no_sneak_preview') { $templates = array('rss-podcast_no_sneak_preview.php'); } return $templates; } add_filter('feed_template', 'custom_feed_template');
(2) then created a copy of the feed-podcast.php, renamed the file to “rss-name.php” and saved the file to the root directory of the child theme.
(3) then I cleared the cache and reset the display rule
(4) when calling the custom feed URL this error message appears.
Please let me know what I’m missing.
Thanks,
Jan
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom RSS Feed’ is closed to new replies.