• Hi,

    The issue is at this page : https://onirisweb.com/portfolio-2/logos/

    As you can see, I programmed a grid page. But if you use the pagination at the bottom to go to page 2, it doesn’t work, displaying the same page.

    Here is my code :

    <?php
    /*
    Template Name: grid page
    */
    ?>
    <?php get_header(); ?>
    
    <div id="ariane"><?php breadcrumb_trail(); ?></div>
    <div id="main"><!-- Start main -->
    
    <div id="content-home"><!-- Start grid-page  -->
    
    <?php $gridcategory=get_post_meta($post->ID, "grid", true); ?>
    <?php
    query_posts('order=ASC&category_name='.$gridcategory.'&posts_per_page=9'); // Can also be limited to a specific category, like query_posts('cat=4&posts_per_page=1000');
    $counter = 1; // Start the counter
    $grids = 3; // Grids per row
    
    if(have_posts()) : while(have_posts()) : the_post();
    
    // Show all columns except the right hand side column
    if($counter != $grids) :
    ?>
    
    <div class="griditemleft">
    <div class="postimage">
    
     <a href="<?php the_permalink(); ?>?lightbox[width]=760&lightbox[height]=460&lightbox[iframe]=true" title="<?php the_title(); ?>" class="lightbox"><div class="white-bck"><?php the_post_thumbnail( array(150,150) ); ?></div></a>
    </div><!-- .postimage -->
    </div><!-- .griditemleft -->
    
    <?php
    
    // Show the right hand side column
    elseif($counter == $grids) :
    ?>
    <div class="griditemright">
    <div class="postimage">
    <a href="<?php the_permalink(); ?>?lightbox[width]=760&lightbox[height]=460&lightbox[iframe]=true" title="<?php the_title(); ?>" class="lightbox"><div class="white-bck"><?php the_post_thumbnail( array(150,150) ); ?></div></a>
    </div><!-- .postimage -->
    </div><!-- .griditemright -->
    
    <div class="clear"></div>
    
    <?php
    $counter = 0;
    endif;
    $counter++;
    endwhile;  ?>
    <?php if (function_exists("pagination")) {
    
        pagination($additional_loop->max_num_pages);
    
    } ?>
    <?php endif; ?>
    
    </div><!-- End grid-page  -->
    
    <?php get_sidebar(); ?>
    </div><!-- End main -->
    
    <?php get_footer(); ?>
    <script type="text/javascript">
      jQuery(document).ready(function($){
        $('.lightbox').lightbox();
      });
    </script>
    </body>
    </html>

    It’s now several days that I spend to understand what’s the matter, but I don’t understand why it doesn’t work.

    Anybody’s an idea ?

    Thanks for your help.

Viewing 1 replies (of 1 total)
  • I see two things that could be causing the problem.

    First, in order for pagination to work, you must include the ‘paged’ argument to your query:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('paged='.$paged.'&order=ASC&category_name='.$gridcategory.'&posts_per_page=9'); // Can also be limited to a specific category, like query_posts('cat=4&posts_per_page=1000');

    Second, the pagination seems to depend on a query called ‘$additional_loop’. That query does not seem to be defined in the code you showed. Try using this instead:

    pagination($wp_query->max_num_pages);
Viewing 1 replies (of 1 total)
  • The topic ‘Problem with pagination in grid page’ is closed to new replies.