Support » Fixing WordPress » setting sortby

  • 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ryan Boren


    WordPress Dev

    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');

    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


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘setting sortby’ is closed to new replies.