[wp-hackers] How to remove captions on the homepage

Alex Hempton-Smith hempsworth at googlemail.com
Wed Jan 14 18:44:58 GMT 2009


> if ( is_home() ) {
>       add_filter('img_caption_shortcode', create_function('$a, $b, $c',
'return $c;'), 10, 3);> };

That works in the header.php great, but I'm still getting the <img> tag, and
therefore the image, outputted.

I've tried filtering out the <img> using the following methods, but they
BOTH seem to break the above filter and the [caption] is outputted but no
<img> - very strange! Here are the methods I've tried:

$pattern = '/<img[^>]+>/is';
$string = get_the_content();
$string = preg_replace($pattern, '', $string);
echo $string;

AND

echo strip_tags(get_the_content(''),
'<p><a><h2><blockquote><code><ul><li><i><em><strong>');

Any other ideas of how I could get rid of the pesky <img>?

Cheers,
-- Alex


More information about the wp-hackers mailing list