Support » Plugin: WP-PageNavi » Next pages not working on Category.php, but it does work on an other custom page

  • Resolved bobbyalpha

    (@bobbyalpha)


    I spend hours to search on the internet and still got no solution for this problem. I’m building a website with custom category pages. I got one page where all categories are showd(this page works well). And the specific pages for the categories doesn’t work(category.php). When I click on page 2 -> page/2 it shows a 404 error. When I change /Page/2 to /?page=2 it shows the correct page.

    Does someone know how to fix this problem I already spend hours on this problem.

    https://wordpress.org/plugins/wp-pagenavi/

Viewing 1 replies (of 1 total)
  • Thread Starter bobbyalpha

    (@bobbyalpha)

    <?php
                                if (get_query_var('paged')) {
                                    // On a paged page.
                                    $paged = get_query_var('paged');
                                } else if (get_query_var('page')) {
                                    // On a "static" page.
                                    $paged = get_query_var('page');
                                }
    // Default.
                                else {
                                    $paged = 1;
                                }
    
                                    $args = array('post_type' => 'stoelen', 'category_name' =>  $yourcat->slug , 'orderby' => 'menu_order', 'order' => 'ASC', 'paged' => $paged);
                                // The Query
                                $the_query = new WP_Query($args);
    
                                // The Loop
                                if ($the_query->have_posts()) {
                                    ?>
    
                                    <?php
                                    while ($the_query->have_posts()) {
                                        $the_query->the_post();
                                        ?> 
    
                                        <div class="col-md-4 column">
                                             <div class="columnImage">
                                            <?php $image = get_the_post_thumbnail($post->ID, 'full');if (!empty($image)) { ?>  <a href="<?php echo get_permalink($post->ID); ?>"><div class="columnWrapper"></div><?php echo $image; ?></a><?php } ?>
                                            </div>
                                            <div class="columnContent">
                                                <h3><?php the_title(); ?></h3>
                                                <p><?php the_content(); ?> </p><a href="<?php echo get_permalink($post->ID); ?>">lees meer</a>
                                            </div>
                                        </div>
    
                                        <?php
                                    }
                                    ?>
                                    <div class="navigation">
                                   <?php wp_pagenavi( array( 'query' => $the_query ) ); ?>
                                    </div>
                                        <?php
                                    } else {
                                        // no posts found
                                    }
                                    /* Restore original Post Data */
                                    wp_reset_postdata();
                                    ?>

    This is my code on the category.php page

Viewing 1 replies (of 1 total)
  • The topic ‘Next pages not working on Category.php, but it does work on an other custom page’ is closed to new replies.