WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's seems that this bug of WP never was solved by WP team.

I have custom post-type, my url structure is /%category%/%postname%/ And if i click on 2nd page i will get 404 error.

I tried everything i found on internet, plugins, codes.. i even changed my pagination base url to NOT be page, so wp don't think that i'm searching for post-type named page. But still nothing.

And yes i did the resave process of permalinks, i've tried restoring to deafault and then go back, still nothing... Downloaded wp_navi still the same..

Is there anything i can do to solve this?

share|improve this question
I found something like that, it has to do with altering the query. Do you use WP_Query or query_posts() ? – Simon Aug 7 '12 at 20:19
up vote 1 down vote accepted

Have you tried this?

I had gotten the same problem before. I did these steps, and it works for me.

I use this code in my functions.php

// New method of WordPress Query since 3.4.1
if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) {
    function ucc_add_cpts_to_pre_get_posts( $query ) {
    if ( $query->is_main_query() && ! is_post_type_archive() && ! is_archive() && ! is_search() && ! is_singular() && ! is_404() ) {
        $my_post_type = get_query_var( 'post_type' );
        if ( empty( $my_post_type ) ) {
            $query->set('post_type', 'your_post_type_name'); // replace your_post_type_name with yours
}add_action( 'pre_get_posts', 'ucc_add_cpts_to_pre_get_posts' );

Then, I use this in my single-{post-type}.php

<?php $paged = 1;
  if ( get_query_var('paged') ) $paged = get_query_var('paged');
  if ( get_query_var('page') ) $paged = get_query_var('page'); 
  if (have_posts()): 

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $loop = new WP_Query( array(
    'post_type' => 'your_post_type_name', // replace your_post_type_name with yours
    'posts_per_page' => PER_PAGE_DEFAULT, // Displaying number posts per page equals to Reading Settings in WP admin

<?php query_posts( '&post_type=your_post_type_name&paged=' . $paged );  ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

  <!-- The content is here -->

<?php endwhile; else: ?>
  <p>Not Found</p>
<?php endif; wp_reset_query(); ?>

<div class="navigation">
 <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?> 

In my case, I use wp page numbers plugin.

Hopefuly, it can solve your problem.

share|improve this answer
your function is WAY to long for such thing, but i will accept it because maybe some will find it useful. Thanks. :) – Tommixoft Sep 4 '12 at 11:39

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.