Pagination on child category returns 404

Can anyone figure out why viewing pages in my child categories results in a 404, when the same $paged code works fine for my index file? This is inside of my category-15.php (it’s to affect all child categories under parent category ID 15).

  <?php
    $PostNum = 1;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'cat' => $cat,
        'posts_per_page' => 2,
        'orderby' => 'date',
        'order' => 'ASC',
        'paged' => $paged,
    );
    $CustomQueryIdentifier = new WP_Query($args);
  ?>

    <h1><a href="<?php the_permalink(); ?>"><?php the_category(' '); ?></a></h1>

    <?php
      if ( $CustomQueryIdentifier->have_posts() ) : while ( $CustomQueryIdentifier->have_posts() ) : $CustomQueryIdentifier->the_post();
    ?>
    <div class="container">
      <p class="number"><a href="<?php the_permalink(); ?>"><?php $postnumber = $CustomQueryIdentifier->current_post; echo $postnumber+1 ?></a></p>
      <?php the_content(''); ?>
    </div>

  <?php endwhile; endif; ?>

  <div class="navigation">
    <?php next_posts_link('&laquo; Older Entries', $CustomQueryIdentifier->max_num_pages) ?>
    <?php previous_posts_link('Newer Entries &raquo;') ?>
  </div>

  <?php wp_reset_postdata(); ?>

Read more here: Pagination on child category returns 404

Leave a Reply

Your email address will not be published. Required fields are marked *