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

Alex Hempton-Smith hempsworth at googlemail.com
Wed Jan 14 19:10:43 GMT 2009


Brilliant, thanks Ozz and Otto for your input, works a charm now.
Lynn, the final piece of code to be placed in header.php is:

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

-- Alex


On Wed, Jan 14, 2009 at 7:03 PM, Otto <otto at ottodestruct.com> wrote:

> 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
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list