WordPress.org

Ready to get started?Download WordPress

Forums

setting sortby (3 posts)

  1. dmclark
    Member
    Posted 9 years ago #

    Hi,
    
    I thought I understood filters, but I guess not.

    I'm trying to have all listings (other than home page) display in alphabetical ordero.

    I have:

    function order_query($query_vars) {
    if (!is_home())
    {$query_vars['orderby'] = 'title';}
    return $query_vars;
    }

    add_filter('query_vars', 'order_query');

    no luck.

    any ideas?

  2. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    You need to use query_string not query_vars.

    function order_query($query_string) {
    if (!is_home()) {
    $query_string = add_query_arg('orderby', 'title', $query_string);
    }
    return $query_string;
    }

    add_filter('query_string', 'order_query');

  3. dmclark
    Member
    Posted 9 years ago #

    Ah, ok, this helps a tad.

    My problem now is that these are appended on to $wp_query in a weir way, and I end up with something like

    cat=22&full=1?orderby=tittle&order=asc&posts_per_page=10000

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.