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

Otto otto at ottodestruct.com
Tue Apr 5 18:35:59 UTC 2011


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


More information about the wp-hackers mailing list