[wp-hackers] Multiple orderby and order options in WP_Query

lonnyk at gmail.com lonnyk at gmail.com
Tue Apr 5 19:08:32 UTC 2011


What happens when you call 'remove_filter' from inside the run_once  
function and call the filter twice?

On Apr 5, 2011 2:35pm, Otto <otto at ottodestruct.com> wrote:
> On Tue, Apr 5, 2011 at 12:33 PM, scribu mail at scribu.net> wrote:

> >> add_filter( 'posts_orderby', 'my_order' );

> >> $blah = new WP_Query(...);

> >> remove_filter( 'posts_orderby', 'my_order' );

> >

> >

> > Yeah, except remove_filter() will remove all callbacks attached to

> > posts_orderby, due to this bug:

> >

> > http://core.trac.wordpress.org/ticket/9968





> Bug doesn't apply. The remove_filter() function, in this case, works

> and does what you would expect it to do. It doesn't remove all

> callbacks.



> This code works perfectly, for example:



> function run_once() {

> return 'test';

> }

> add_filter( 'foobar', 'run_once' );



> function another_filter() {

> return 'test again';

> }

> add_filter( 'foobar', 'another_filter', 11 );



> remove_filter( 'foobar', 'run_once' );



> echo apply_filters( 'foobar', '' ); // produces "test again"



> -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