Articles of add feed

Custom RSS feed forces download

I’m trying to implement a custom RSS feed that is formatted for podcasting and pulls in the audio file from an Advanced Custom Field. Basically I’ve been working off of the example provided here: https://css-tricks.com/roll-simple-wordpress-podcast-plugin/ My plugin looks like this: // add a custom RSS feed function podcast_rss(){ add_feed(‘podcast’, ‘run_podcast_rss’); } add_action(‘init’, ‘podcast_rss’); function run_podcast_rss(){ […]

add_feed and flush_rewrite_rules

There seems to be quite a controversial opinion on the WordPress flush_rewrite_rules() function. According to the Codex, it is highly discouraged to use this function on the init action hook. However: In a plugin I am working on, I am using add_feed() to, well, add a feed. The Codex says that this should be run […]

Cannot get add_feed to work

I want to add a custom feed on my site for SEO purposes. So, I first copy the /wp-includes/feed-rss2.php file into my theme folder and renamed it. I figured I’ll be able to easily edit my feed. Then I add this code : function yandex_news_feed() { load_template(TEMPLATEPATH . ‘/yandex-news.php’); } function yandexnews_add_feed() { add_feed(‘do_feed_yandexnews’, ‘yandex_news_feed’); […]

Change of query var in pre_get_posts not maintained

I’m creating a plugin that adds a custom feed. I am using a pre_get_posts filter to change the posts_per_page query var to -1 (to get all items of a custom post type). However, if I dump the $wp_query in the render function, posts_per_page remains the default. I tested also changing posts_per_rss to -1, and I […]

Yoast custom feed template as add_feed function?

I’m trying to make Yoast’s Custom RSS feeds post display in an add_feed function. Just putting Yoast’s snippet inside add_feed results in: ERROR: feedname is not a valid feed template. I have tried two rewrite functions, but to no avail. What could I be missing? Yoast’s function untouched: <?php /* Template Name: Custom Feed */ […]

Possible to use conditionals within add_feed() callback?

I’m using add_feed() to create some custom feeds but calls to is_singular(), is_home() etc… just don’t seem to work within the callback. Is there a workaround for this? Example code: add_action( ‘init’, ‘my_init’ ); function my_init() { add_feed( ‘new_feed’, ‘feed_output’ ); } function feed_output() { if ( is_home() ) load_template( ‘/path/to/feed/home/template.php’ ); else load_template( ‘/path/to/feed/template.php’ […]

How to flush feed? Or set timeout on feed so that it isn't cached?

I’m trying to add a custom feed format to my site (basically exporting data to an Excel file) and I’m getting confused by the feed caching settings. I can’t figure out how to flush the cached feeds, or to turn off feed caching altogether while I’m in development. I’ve tried deleting all the _transient_feed…, _transient_timeout_feed… […]