Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a filter on the get_bookmarks function. When I use two arguments in my filter function I get the result array and nothing for the second arg (it should be the parsed query).

Here's what I'm mean:

function samiconductor_sort_links_by_order( $results, $args ) {
    echo print_r($args); // nothing

    function order($a, $b) {
        $a_order = get_option( "link_order_$a->link_id", 0 );
        $b_order = get_option( "link_order_$b->link_id", 0 );

        if ( $a_order == $b_order ) {
            return 0;
        }
        return ( $a_order > $b_order ) ? -1 : 1;
    }

    usort( $results, order );

    return array_reverse($results);
}
add_filter( 'get_bookmarks', 'samiconductor_sort_links_by_order' );

And here's the get_bookmarks function - source.

As you can see, it should pass $r = wp_parse_args( $args, $defaults ); as the second arg to the filter.

Am I missing something?

Thanks

share|improve this question
add comment

1 Answer

By default add_filter() instructs WP to only pass first parameter to your hooked function. If you want more you need to specify that (and priority which comes earlier and defaults to 10):

add_filter( 'get_bookmarks', 'samiconductor_sort_links_by_order', 10, 2 );
share|improve this answer
    
Ok, sweet! That's easy! Thanks so much! –  user4392 Apr 3 '11 at 5:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.