2017-07-19 36 views
1

我有一個組合的Wordpress頁面,我需要排序這首先顯示選擇「精選」類別的帖子。排序帖子顯示第一個帖子與選定的類別

所有的項目都有一個類似「桌子」,「椅子」......我可以過濾,但我需要,如果我標記與「精選」類別的項目,這出現在頂部的列出我是否將所有產品或產品展示在類別中(ej:表格)。

你能幫我嗎?

在此先感謝

+0

粘貼您使用功能比其他類別排序的代碼 –

回答

0

最後,我已經解決了這個問題,這種方法:

<?php 
    //Get posts with "Featured" category 
    $featured= query_posts('post_type=portfolio&projecttype=featured&posts_per_page=-1'); 
    //Get all posts 
    $posts=query_posts('post_type=portfolio&project-type='. query_categories() .'&posts_per_page=-1'); 

    //I merge removing duplicated posts with array_unique 
    $final_posts = array_unique(array_merge($destacados, $posts), SORT_REGULAR); 

    foreach ($final_posts as $key => $post) { 
     setup_postdata($post); 

     //Use wp methods to show info (ej:the_title();) 
    } 
?>