There is some iframe inside post content and I want to get rid of that iframe when the rss feeds are generated. To generate rss feeds, I’m showing full post content.
I started looking at strip_tags()
but it does pretty much the opposite: strip everything unless the desired tags.
I’m wondering that maybe there is some hook and some wordpress-y form of solving this issue.
I know I should do something like this:
function rss_noiframe($content) {
global $post;
// filter out iframe here
return $content;
}
add_filter('the_excerpt_rss', 'rss_noiframe');
add_filter('the_content_feed', 'rss_noiframe');
But I’m lost at this point. Any ideas?
On demand by EAmann, here is some example code that isnt modified at all (it still appears in the feed, in fact):
<iframe src="http://somedomain.net/path/to/frame" frameborder="0" scrolling="no" width="500" height="375"></iframe>
One potential option is to use
preg_replace
to do a regex match on your content and replace the iframe with empty space.So this function:
Should automatically convert any instances of
<iframe src=...>...</iframe>
to a blank.