0

我在分页结果中显示我的类别页面时遇到问题

我有一个名为“视频”的自定义帖子类型

我把这种类型的所有帖子放在一个类别名称“汽车视频”中

我使用模板页面 category-9.php' 作为该类别“汽车视频”的 id 是“9”

我将此代码放在 category-9.php

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
?>
    <?php query_posts( $query_string . '&post_type=videos&posts_per_page=10&paged=' . $paged ); ?>
    <?php if ( have_posts() ) : ?>
        <?php
        /* Start the Loop */
        while ( have_posts() ) : the_post();
            /* Include the post format-specific template for the content. If you want to
             * this in a child theme then include a file called called content-___.php
             * (where ___ is the post format) and that will be used instead.
             */
            get_template_part( 'content', 'videos' );

        endwhile;

        // twentytwelve_content_nav( 'nav-below' );
        ?>
    <?php paging(); ?>
    <?php else : ?>
        <?php get_template_part( 'content', 'none' ); ?>
    <?php endif; ?>

我的第一页“sitename.com/blog/category/cat-videos/”工作正常,但我的这些页面无法正常工作

'sitename.com/blog/category/cat-videos/page/1'

'sitename.com/blog/category/cat-videos/page/2'

ETC..

它给了我 404.php 页面

这是自定义帖子注册

$post_type_args = array(
'label' => 'Videos',
'labels' => array(
    'name' => 'Videos',
    'singular_name' => 'Video',
    'menu_name' => 'Videos'
),
'public' => true,
'has_archive' => true,
'hierarchical' => true,
'supports' => array('title','author','thumbnail','comments'),
'rewrite' => array('slug' => 'videos'),
'taxonomies' => array('category','post_tag')

);


register_post_type('videos',$post_type_args);

有什么建议吗?

4

1 回答 1

2

我对你的有一些问题,我找到了将这段代码放入 function.php 的解决方案。一切正常

    function fix_category_pagination($qs){
    if(isset($qs['category_name']) && isset($qs['paged'])){
        $qs['post_type'] = get_post_types($args = array(
            'public'   => true,
            '_builtin' => false
        ));
        array_push($qs['post_type'],'post');
    }
    return $qs;
}
add_filter('request', 'fix_category_pagination');
于 2013-11-29T17:49:44.690 回答