目前我已经安装了wordpress v4。7.2并创建了一个儿童主题twentyfifteen
我已经创建了custom post type.
现在当浏览
localhost, 我得到了应为的列表,但分页不起作用:(:
例如page2 points
本地主机/第页/2/
--
作为访问时localhost/works
分页工作正常
我使用的代码也在archive 和template 文件,如下所示:
// Previous/next page navigation.
the_posts_pagination( array(
\'prev_text\' => __( \'Previous page\', \'twentyfifteen\' ),
\'next_text\' => __( \'Next page\', \'twentyfifteen\' ),
\'before_page_number\' => \'<span class="meta-nav screen-reader-text">\' . __( \'Page\', \'twentyfifteen\' ) . \' </span>\',
) );
<!--when WORKS is as default page homepage-->
works-template.php
<!--when access it via localhost/works-->
archive-works.php
唯一不同的是
works-template.php, 调用
query_posts()<?php
$posts_per_page = get_query_var(\'posts_per_page\');
$paged = ( get_query_var(\'page\') ) ? get_query_var(\'page\') : 1;
$args = array(\'post_type\' => \'works\',\'posts_per_page\'=> $posts_per_page ,\'post_status\' => \'publish\' ,\'orderby\' => \'menu_order\',\'order\' => \'ASC\',\'paged\' =>$paged);
query_posts( $args );
// Start the Loop.
while ( have_posts() ) : the_post();
有什么建议吗?