I think it would be better to create a custom feed, for such modifications.
That way, the default feed is unaffected.
We can look at how add_feed()
works and where to hook it.
Add a custom one, like: add_feed( 'ucnews', '...some custom callback...' );
There exists e.g. the core do_feed_rss2()
function, that loads the default rss2 template:
load_template( ABSPATH . WPINC . '/feed-rss2.php' );
There the <content:encoded>
tag gets it's value from get_the_content_feed()
, so we can filter it with the_content_feed
.
That way we can filter the content, only for that feed, e.g. with the help from a is_feed( 'ucnews' )
check.
Note that one needs to flush the rewrite rules, for the custom feed rules to be activated.
It's also not clear if this is for all iframes, or only specific ones!
I'm not sure how effective a preg_replace
would be, in this case, so you might try a shortcode approach instead, where the output could depend on the context.
Hope it helps!