Category pagination not working in custom post type

I have a problem showing my category page in pagination results

I have a custom post type named ‘videos’

Read More

I put all the posts of this type in a one category names ‘cars video’

I use a template page category-9.php’ as the id of this category ‘cars video’ is ‘9’

I place this code in 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; ?>

I got the first page ‘sitename.com/blog/category/cat-videos/’ working fine but I have this pages not working

‘sitename.com/blog/category/cat-videos/page/1’

‘sitename.com/blog/category/cat-videos/page/2’

etc..

it gave me 404.php page

This is the custom post registration

$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);

Any advices?

Related posts

Leave a Reply

1 comment

  1. I have some problem with yours, and i found the solution with put this code in to function.php. And everything working fine

        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');