2016-11-18 30 views
0

我有一個名爲'Product'的元素鍵爲'Prioritized'的自定義帖子。我在帖子中添加了很多草稿。現在,在管理員中,我想對帖子進行排序,以便按照用戶列出產品列表。 我已經嘗試過很多插件,但沒有一個符合我的要求。我只想將那些發佈和檢查的帖子排序爲優先。 這可能嗎? 歡迎任何幫助/建議。 在此先感謝。如何在wordpress中基於元鍵訂購自定義帖子admin

回答

0

請嘗試下面的代碼

$args = array(
    'post_type'  => 'your-post-type', 
    'posts_per_page' => 1, 
    'post_status' => array('publish'), 
    'meta_key'  => 'your key name',//prioritized 
    'meta_value'  => 'your key value' 
); 

$the_query = new WP_Query($args); 

if ($the_query->have_posts()) : 
    while ($the_query->have_posts()) : $the_query->the_post(); 
     the_title(); 
    endwhile; 
endif; 
+1

這將是在網站的前端做到這一點的方法,但我對問題的理解是關於管理區域。 –

0

您可以通過this plugin顯示作者和自定義字段列。我不確定你能否按這個字段排序行。

相關問題