[wp-hackers] add_filter before or after function?

Jennifer Hodgdon yahgrp at poplarware.com
Thu Aug 30 02:03:53 GMT 2007

Jeremy Visser wrote:
> DD32 wrote:
>> add_filter('query_vars', 'test_queryvars' );
>> function test_queryvars( $qvars ){
>>     $qvars[] = 'artist_slug';
>>     $qvars[] = 'artist_page';
>>     return $qvars;
>> }
> I notice you add the add_filter() _before_ you declare the actual
> function. Others do that too, while other add the add_filter() (or
> add_action()) _after_ the function.
> Which is best?

Actually, it doesn't matter. When you call add_filter, you are only 
passing in the name of the function you want to use later for 
filtering. By the time WP calls the function to filter something, the 
function will be defined.


Jennifer Hodgdon

Poplar ProductivityWare * www.poplarware.com
Web Databases/Scripts * Modeling/Analysis/Palm OS Software

More information about the wp-hackers mailing list