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

Otto otto at ottodestruct.com
Wed Jan 14 19:03:32 GMT 2009


On Wed, Jan 14, 2009 at 12:44 PM, Alex Hempton-Smith
<hempsworth at googlemail.com> wrote:
>> 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
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


I think you can just change the return $c; to return ""; and it'll work.

I have not tried it, so buyer beware.

-Otto


More information about the wp-hackers mailing list