• Hi,

    I’m having trouble sorting posts.

    This works (I’m using it from the parse_query filter):

    $query->set('orderby', 'post_date');
    $query->set('order', 'DESC');

    But this (with works for non-relevanssi queries) does nothing:

    $query->set('meta_key', 'my_meta_field');
    $query->set('orderby', 'meta_value');
    $query->set('order', 'DESC');

    Is there a way to do this? Or is this just not possible with relevanssi?

    Thanks,
    Tom

    https://ww.wp.xz.cn/plugins/relevanssi/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    No, it doesn’t work like that in Relevanssi. If you want to sort by a meta field, you need to do it manually. With relevanssi_hits_filter you get complete control over the search results, and can sort them anyway you want, including meta values.

    Thread Starter mallorydxw-old

    (@tomdxw)

    That solves my problem. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Sorting by meta_value’ is closed to new replies.