0
我有一個名爲「sale_status」的自定義字段,值(「出售」,「出售」,「讓」)顯示在管理單選按鈕中。現在,每個人都可以分配到一個屬性。通過wordpress中的多個自定義字段值排序
目前查詢通過發佈日期提取屬性順序,但我希望它是由sale_status然後日期。
我的代碼below--
$args = array(
'post_type' => 'zoo-property',
'posts_per_page' => $query__per_page,
'post_status' => 'publish',
'paged' => $query__page,
'meta_key' => 'sale_status',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'AND',
$query__types,
$query__locations,
$query__statuses,
$query__investments,
$query__price
)
);
$properties_wp_query = new WP_Query($args);
echo "Last SQL-Query: {$properties_wp_query->request}";
但在正確的順序也沒有顯示。
任何幫助,高度讚賞。提前致謝。
你也可以使用meta_value_num meta_value_num。只有當您想爲每個有序字段設置不同的排序順序時,才需要該數組(該功能[已添加到WP 4.0中](https://make.wordpress.org/core/2014/08/29/a-more -powerful階由合的wordpress-4-0 /))。 – vard
感謝您指出這一點! – Technoh
@Technoh非常感謝您的幫助。它像一個魅力。只是想知道是否有可能首先顯示全部「待售」,然後是全部「已售出」,然後全部「讓」 – Raj