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?



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 );
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy