2015-12-01 163 views
0

無法讓自定義分類在自定義帖子類型分類頁面上工作。它在顯示自定義存檔頁面時起作用。當我點擊頁面時,它會顯示來自第一頁的帖子,但該URL表示頁面= 2。Pagnation wordpress自定義帖子類型分類頁面

這是我在archive-slug.php中使用的代碼。我如何定製它來處理taxonomy-slug.php?

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts(array('post_type' => 'dropshippers', 'paged' => $paged)); 
$loop = new WP_Query(array('post_type' => 'dropshippers', 'paged' => get_query_var('paged'), 'posts_per_page' => 8)); 
if(have_posts()) : while(have_posts()) : the_post(); 

//Posts 

endwhile; endif; 

if(function_exists('wp_pagenavi')) { 
wp_pagenavi(array('query' => $loop)); 
} else { 
echo "No posts"; 
} 

回答

1

您需要在您的查詢添加你的名字類別,我更喜歡使用get_posts爲:

<?php $args = array(
    'posts_per_page' => 8, 
    'offset'   => 0, 
    'category'   => '', 
    'category_name' => '', 
    'orderby'   => 'date', 
    'order'   => 'DESC', 
    'include'   => '', 
    'exclude'   => '', 
    'meta_key'   => '', 
    'meta_value'  => '', 
    'post_type'  => 'dropshippers', 
    'post_mime_type' => '', 
    'post_parent'  => '', 
    'author'  => '', 
    'post_status'  => 'publish', 
    'suppress_filters' => true 
); 
$posts_array = get_posts($args); ?> 

Fullfit這兩個線路與ARGS:

'category'   => '', 
'category_name' => '', 
相關問題