分页数字自定义帖子类型wordpress

时间:2017-01-19 23:55:44

标签: 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 );

1 个答案:

答案 0 :(得分: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.