1. Docs
  2. Developer Guide
  3. Miscellaneous and Snippets
  4. Changing the default sort order of properties

Changing the default sort order of properties

If you have our free Template Assistant add on installed you can do it using that under 'Property Hive > Settings > Template Assistant > Search Results'.

Alternatively, to change the default sort order of properties shown in search results you can add the following to your theme’s functions.php file:

add_filter('propertyhive_default_search_results_orderby', 'change_default_order');
function change_default_order( $orderby )
{
    if (
        ( isset($_REQUEST['department']) && $_REQUEST['department'] != 'commercial' ) ||
        ( !isset($_REQUEST['department']) && get_option( 'propertyhive_primary_department' ) != 'commercial' )
    )
    {
        return 'price-asc'; // e.g price-asc, date, modified etc
    }
    else
    {
        return $orderby;
    }
}
Was this article helpful to you? Yes No