2017-01-19 80 views
0

任何人都知道我可以如何使用wordpress中的自定義文章類型進行數字分頁?分頁數字自定義文章類型wordpress

$posts_per_page = 10; 
$post_type = 'products' 

$args = array('post_type'=> $post_type, 'posts_per_page' => $posts_per_page, 'paged' => get_query_var('paged')); 

query_posts($args); 

回答

0
$args = array('post_type'=> $post_type, 'posts_per_page' => $posts_per_page, 'paged' => get_query_var('paged')); 

$the_query = new WP_Query($args); 
//Your post loop goes here... 
//Get the posts and show your post datas however you want; 

一旦你完成獲得的職位,嘗試了分頁下面的代碼

$big = 999999999; // need an unlikely integer 

echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)), 
'format' => '?paged=%#%', 
'current' => max(1, get_query_var('paged')), 
'total' => $the_query->max_num_pages 
)); 

wp_reset_postdata(); 

類似的解決方案,可以發現here.

相關問題