Forum Replies Created

Viewing 1 replies (of 1 total)
  • maanlander

    (@maanlander)

    Hi, thanks to you I finally found the solution for my pagination problem! Really useful! I used it in a slightly different way. Still there are a few problems:

    1) Does anybody of you know if there’s a possibility to put this script in front of ‘the loop’ instead of after? I’d like to have pagination above my posts as well.

    2) And I miss a ‘previous’ link when on page 2 or further, any ideas? My ‘next’ link needs some work too, can somebody tell me what it is I’m doing wrong?

    This is the code I have now:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $loopb = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 2, 'paged' => $paged ) ); ?>
    <?php while ( $loopb->have_posts() ) : $loopb->the_post(); 
    
    //display posts
    ?>
    <?php endwhile; ?>
    <?php
    if($loopb->max_num_pages>1){?>
        <p class="navrechts">
        <?php
        for($i=1;$i<=$loopb->max_num_pages;$i++){?>
            <a href="<?php echo '?paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
            <?php
        }
        if($paged!=$loopb->max_num_pages){?>
            <a href="<?php echo '?paged=' . $i; //next link ?>">></a>
        <?php } ?>
        </p>
    <?php } ?>

    Hope someone can help me!

Viewing 1 replies (of 1 total)