• Hi forum users,

    I recently have been messing around with my category pages in archive.php. In an effort to sort the category posts by name rather than date, I replace this:

    if ( have_posts() ) :
                        while ( have_posts() ) :
                            the_post();
                            get_template_part("template-parts/article-for-listing");
                        endwhile;
                        theme_pagination( $wp_query->max_num_pages);
                    else :
                        ?>
                        <h3><?php _e('No Result Found!', 'framework'); ?></h3>
                        <?php
                    endif;

    with this:

    $articles_list = new WP_Query( array(
                       'cat' => $cat,
                       'orderby' => 'title',
                       'order' => 'ASC'
                   ));
    
                   if ( $articles_list->have_posts() ) :
                       while ( $articles_list->have_posts() ) :
                            $articles_list->the_post();
                            get_template_part("template-parts/article-for-listing");
                        endwhile;
                        theme_pagination( $wp_query->max_num_pages);
                    else :
                        ?>
                        <h3><?php _e('No Result Found!', 'framework'); ?></h3>
                        <?php
                    endif;

    It sorted it the way I wanted. However, when you click for the next page in any category area, the same page repeats over and over. Here’s an example page for you to look at. Any clue what’s going on or how to fix it?

    I’m not too good with CSS.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category pagination broken. Keeps repeating same page—Not sure why.’ is closed to new replies.