Live Filter – set default sort option

With the Live Filter feature in Pro version, you can show sort options in frontend, to help your users to sort content themselves.
To set the default sort option, please add this code to Custom JS field (the right textarea) in Content Views >> Settings page:

var viewid = 'VIEW_ID', default_sort = 'SORT_VALUE';
if ($('[data-sid="' + viewid + '"] [name="_orderby"]').val() == '') {
    $('[data-sid="' + viewid + '"] [name="_orderby"]').val(default_sort).trigger('change');
}

then:

  • replace VIEW_ID with ID of your View
  • replace SORT_VALUE with the sort option you want to set as default, it can be title, date, or custom field key (to get correct custom field key, select that field from the live filter, the URL will change to ?_orderby=FIELD_KEY, then copy the FIELD_KEY in URL).

Best regards,