My feed uses the excerpt, and I want to remove a line of code containing an image.
Example format is...
<img class="pagehead" src="/graphics/magazine/307/1.jpg" alt="" />
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityMy feed uses the excerpt, and I want to remove a line of code containing an image.
Example format is...
<img class="pagehead" src="/graphics/magazine/307/1.jpg" alt="" />
UPDATE...
Answering my own question, I'll add this in the hope it'll be useful to someone...
Whilst waiting for answers, I found a solution which seems to work fine.
function remove_images( $the_excerpt_rss ) {
$postOutput = preg_replace('/<img[^>]+./','', $the_excerpt_rss);
return $postOutput;}
add_filter( 'the_excerpt_rss', 'remove_images', 100 );
You can customize your feed like any other template and use the_excerpt_rss function:
<?php the_excerpt_rss( $cut, $encode_html ); ?>
Or maybe use PHP strip_tags function :
// Autorise <p> et <a>
echo strip_tags( $text, '<p><a>' );