From 23108c3cf7eade042dd4efeb30bd63b693fd010f Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Wed, 11 Dec 2019 15:59:02 +0700 Subject: [PATCH] Fix order properties. --- inc/property/class-opalestate-search.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index fb98abe0..7b5aba87 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -241,13 +241,17 @@ class OpalEstate_Search { } if ( ! empty( $ksearchs ) && count( $ksearchs ) == 2 ) { - $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0]; - $args['orderby'] = ( 'featured' !== $ksearchs[0] ) ? 'meta_value_num' : 'meta_value'; - $args['order'] = $ksearchs[1]; + if ( 'featured' === $ksearchs[0] ) { + $args['orderby'] = [ 'meta_value' => 'DESC', 'date' => 'DESC' ]; + $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured'; + } else { + $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0]; + $args['orderby'] = 'meta_value_num'; + $args['order'] = $ksearchs[1]; + } } elseif ( 'on' == opalestate_options( 'show_featured_first', 'off' ) ) { + $args['orderby'] = [ 'meta_value' => 'DESC', 'date' => 'DESC' ]; $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured'; - $args['orderby'] = 'meta_value'; - $args['order'] = 'DESC'; } $metas = Opalestate_Property_MetaBox::metaboxes_info_fields();