WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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

Your Answer


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