[wp-hackers] Passing arguments to filter functions.

Andrew Nacin wp at andrewnacin.com
Mon Feb 28 07:56:10 UTC 2011


On Mon, Feb 28, 2011 at 2:46 AM, Satish Gandham <satish.iitg at gmail.com>wrote:

> See the get_the_post_thumbnail function in the file below
>
>
> http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/post-thumbnail-template.php
>
> If im using post_thumbnail_html filter
>
> add_filter( 'post_thumbnail_html', 'swift_post_image_html', 10, 3 );
>
>  Is there a way to access the $attr variable swift_post_image_html'() ?


Yes. The filter has five total arguments, with $attr being the fifth:

apply_filters( 'post_thumbnail_html', $html, $post_id,
$post_thumbnail_id, $size, $attr )


You're only asking for three. Try this:

add_filter( 'post_thumbnail_html', 'swift_post_image_html', 10, 5 );

Cheers,
Nacin


More information about the wp-hackers mailing list