這裏我的解決方案http://codex.wordpress.org/Class_Reference/WP_Query
我做了兩個查詢,在這種情況下,我沒有使用分頁也許this可以幫助
$sticky = get_option('sticky_posts');
$args_nonsticky = array(
'showposts' => -1,
'post__not_in' => $sticky
);
$args_sticky = array(
'posts_per_page' => -1,
'post__in' => $sticky
);
$the_query_sticky = new WP_Query($args_sticky);
$the_query_nonsticky = new WP_Query($args_nonsticky);
if(!$the_query_sticky->have_posts() && !$the_query_nonsticky->have_posts()){
//echo '<h1>NO POSTS FOUND</h1>';
}else{
if ($sticky[0]) {
while ($the_query_sticky->have_posts()) : $the_query_sticky->the_post();
//sticky if so...
endwhile;
}
while ($the_query_nonsticky->have_posts()) : $the_query_nonsticky->the_post();
// non sticky
endwhile;
}
在我的「工具箱」主題的默認index.php的順序把粘性帖子放在頂部,但在我自己的WP_query我不能使它 – chilljul
分類篩選例如對於類別是這樣打破的。您可以添加到查詢參數:'tax_query'=> array('taxonomy'=> get_queried_object() - > taxonomy,'field'=>'id','terms'=> get_queried_object() - > term_id) ) http://wordpress.stackexchange.com/questions/102346/how-to-display-post-from-current-taxonomy-in-archive-page – netAction