Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm seriously going to go crazy if I dont figure this out. I have tried a million different things from googling,a nd I've been staring at this same problem for days now.

Pagination for a custom post type in category.php returns a 404 page for /page/2. If i go to /page/1 it redirects and works fine, but /page/2 breaks.

Permalinks are set to /%postname%/

Ive tried all the fixes I have seen on google, and everyone i try to hire to fix it is stumped. Willing to pay if thats your thing, im so sick of this by now

get_header(); ?>

<div class="home-gradient">
<div id="container">

    <?php include('snippet-post-gallery.php'); ?>

<div class="content-wrap">  


       $catID = get_query_var('cat');
       $catName = strtolower(get_cat_name($catID));

      $myquery = new WP_Query(array(
            'post_type' => 'any',
                'paged' => $paged,
                'posts_per_page' => 1,
          'category_name' => $catName)

        while ( $myquery->have_posts() ) : $myquery->the_post(); 

            $img_id = get_post_meta($post->ID,'main_image',true);
            $img_url = wp_get_attachment_url($img_id);


            <div class="post-box">


       wp_pagenavi( array( 'query' => $myquery ) );

    <?php ?>


        <div class="sidebar-wrap">
            <?php get_sidebar(); ?>

        <br class="clear">

    <?php get_footer(); ?>
share|improve this question
By the way if a mod can make this eligible for bounty now I'll give up all 115 points that i have. –  Tallboy Mar 25 '12 at 16:35
Please try to give this meaningful title. I get that this is frustrating for you, but non-descriptive title doesn't help to get it answered. –  Rarst Mar 25 '12 at 17:21
add comment

2 Answers

up vote 0 down vote accepted
function category_set_post_types( $query ){
    if( $query->is_category ):
        $query->set( 'post_type', 'any' );
    return $query;
add_action( 'pre_get_posts', 'category_set_post_types' );

This worked!

share|improve this answer
add comment

Instead of wp_pagenavi( array( 'query' => $myquery ) ); use the following code if you do not want to display pagintion using pagenavi.

if ( get_next_posts_link() || get_previous_posts_link() ) { 
           next_posts_link( __( '&larr; Older Entries', 'rtPanel' ) );
         previous_posts_link( __( 'Newer Entries &rarr;', 'rtPanel' ) );      
share|improve this answer
I still would like to use it so it matches the rest of the site –  Tallboy Mar 25 '12 at 16:37
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.