首页 > Wordpress 自定义文章类型 翻页 404

Wordpress 自定义文章类型 翻页 404

最近在做一个Wordpress项目,想通过自定义文章类型来给网站增加多种文章类型,因此通过新建插件的方式做了几个文章类型,但在这种文章类型的翻页时会404,更新了固定链接,在后台新建了test页面并指定了模板,但翻页仍然不行!
网站中有其他以分类翻页的,早前也遇到过这个问题,后来也不知道怎么回事就好了,而其他文章类型的翻页都正常……

以下是输出到模块里的代码结构,

<?php 
$limit = get_option(‘posts_per_page’); 
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; 
query_posts(‘post_type=test&showposts=’ . $limit=2 . ‘&paged=’ . $paged); 
$wp_query->is_archive = true; 
$wp_query->is_home = false; 
while ( have_posts() ) : the_post(); 
?>

<中间是内容>

<?php
   endwhile;
   wp_reset_query();
?>


同时,在插件中指定了使用的页面模板,代码如下:
add_filter( 'template_include', 'include_testtemplate_function', 1 );
function include_testtemplate_function( $template_path ) {
    if ( get_post_type() == 'test' ) {
        //指定文章页面
        if ( is_single() ) {
            // checks if the file exists in the theme first,
            // otherwise serve the file from the plugin
            if ( $theme_file = locate_template( array ( 'single-test.php' ) ) ) {
                $template_path = $theme_file;
            } else {
                $template_path = plugin_dir_path( __FILE__ ) . '/single-test.php';
            }
        }
        //指定页面
        elseif ( is_page() ) {
            if ( $theme_file = locate_template( array ( 'page-test.php' ) ) ) {
                $template_path = $theme_file;
            } else { $template_path = plugin_dir_path( __FILE__ ) . '/page-test.php';

            }
        }
        elseif ( is_archive() ) {
            if ( $theme_file = locate_template( array ( 'page-test.php' ) ) ) {
                $template_path = $theme_file;
            } else { $template_path = plugin_dir_path( __FILE__ ) . '/page-test.php';

            }
        }
    }
    return $template_path;
}

请问有遇到过类似问题并且已经解决了的人们;


似乎找到了问题所在,即阅读设置中的博客页面至多显示这个值不能大于post_per_page预设的值,这是为什么呢?而且完全一样的代码,放到另一个模板页面里就可以正常翻页……折腾了很久还是搞不定,求大神!

【热门文章】
【热门文章】