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

On a standard WordPress page, I have a WP Query that runs through a post type I created. Along with that query, I am using paginate_links() to generate pagination. While the standard (no permalinks) seems to work fine - when enabling any permalink combination, the subsequent pagination pages do not load. Here is what I have so far:

$post_args = array(
    'post_type' => 'galleries',
    'paged'     => get_query_var('paged'),
    'post_type' => 'galleries'

$posts_query = new WP_Query($post_args);
$i = 0; // count
$total_items = $posts_query->post_count; // total profiles
$number_columns = $galleries_options['columns']; // number of columns
if ($posts_query->have_posts() ) {
    echo '<div id="galleries-list">';
    while ($posts_query->have_posts() && ($i < $total_items)) { ?>
        <?php $posts_query->the_post(); if ($i % $number_columns == 0) echo ($i > 0 ? '</div><div class="row">' : '<div class="row first-row">'); ?>
        <div class="<?php echo 'width'.intval(100 / $number_columns); ?> <?php if ($i % $number_columns == 0) echo 'first-item'; ?>">
    <?php $i++;
    echo '</div>';
    echo '</div>';

    $total_pages = $posts_query->max_num_pages;
    $big = 999999999; // need an unlikely integer 
    if ($total_pages > 1){  
        $current_page = max(1, get_query_var('paged'));  
        echo '<nav class="page-nav">';  
        echo paginate_links(array(  
            'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
            'format'    => '?paged=%#%',  
            'current'   => $current_page,  
            'total'     => $total_pages,  
            'prev_text' => 'Prev',  
            'next_text' => 'Next'  
        echo '</nav>';  


The default URL is ?page_id=60&paged=2 which works/loads fine - yet galleries/page/2/ does not. Anyone have any suggestions? I'm using the exact same thing for taxonomy pagination... so I'm a bit confused on why this isn't working. Thanks!

share|improve this question
Any reason why you're not using native custom post type/taxonomy archives? – TheDeadMedic Jul 6 '12 at 15:48
This archive is generated via a shortcode that is applied to a page. – Zach Jul 6 '12 at 15:51
Gotcha ;) So when you say "don't load", do you get anything? Does the page that has the shortcode still appear okay? – TheDeadMedic Jul 6 '12 at 15:58
Oddly enough I'm getting a 404 :/ – Zach Jul 6 '12 at 17:16
You should disable rewrite rules for your galleries post type ('rewrite' => false) - they're conflicting with the standard rules for your page with slug galleries. – TheDeadMedic Jul 7 '12 at 9:57
up vote 0 down vote accepted

The issue ended up being the page in which I was accessing the shortcode on was using the same slug - which WP was freaking out about. While I'll need to investigate why it would happen, was easy enough to fix.

share|improve this answer

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.