我在分页结果中显示我的类别页面时遇到问题
我有一个名为'videos'的自定义帖子类型
我把这种类型的所有帖子都放在一个名为'cars video'的帖子中
我使用模板页面类别-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'
等。
它给了我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);
有任何建议吗?
答案 0 :(得分: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');