• Resolved muhammadwaqas

    (@muhammadwaqas)


    I’ve come across a number pagination code for php. It is working 100%. But its not what I have

    <?php
    if($new_query->max_num_pages>1){?>
        <p class="pager">
        <?php
        for($i=1;$i<=$new_query->max_num_pages;$i++){?>
            <a href="<?php echo get_category_link($category_id).'page/'.$i;?>" <?php echo ($paged==$i)? 'class="active"':'';?>><?php echo $i;?></a>
            <?php
        }
        if($paged!=$new_query->max_num_pages){?>
            <a href="<?php echo get_category_link($category_id).'page/'.$i;?>">Siguiente</a>
        <?php } ?>
        </p>
    <?php } ?>

    The result of above code is:

    <p class="pager">
             <a href="page/1" class="active">1</a>
             <a href="page/2" >2</a>
             <a href="4">Siguiente</a>
    </p>

    But I want it to appread like this (using above code), I don’t want 1st and last page links.

    <p class="pager">
             <a href="page/2" rel="2nd">2</a>
    </p>

    I don’t want to use <?php next_posts_link(); ?> because I’ve multiple loops at a single.php and <?php next_posts_link(); ?> create pagination for the current post instead of loop.

    Any help will be appreciated.

    [bump moderated]

Viewing 3 replies - 1 through 3 (of 3 total)
  • try this:

    <?php
    if($new_query->max_num_pages>1){?>
        <p class="pager">
        <?php
        for($i=2;$i<=$new_query->max_num_pages;$i++){?>
            <a href="<?php echo get_category_link($category_id).'page/'.$i;?>" <?php echo ($paged==$i)? 'class="active"':'';?>><?php echo $i;?></a>
            <?php
        }
        <?php } ?>
        </p>
    <?php } ?>
    Thread Starter muhammadwaqas

    (@muhammadwaqas)

    Perfect, its working. Now the result is

    <a href="/page/2" >2</a>
    <a href="/page/3" >3</a>

    Althought I don’t need <a href="/page/3" >3</a>, because I’m using infinite scroll. But still its working ??

    The above code has a syntex error, So here is the good one.

    <?php
    if($new_query->max_num_pages>1){?>
        <p class="pager">
        <?php for($i=2;$i<=$new_query->max_num_pages;$i++){?>
            <a href="<?php echo get_category_link($category_id).'/page/'.$i;?>"><?php echo $i;?></a>
            <?php }?>
        </p>
    <?php } ?>

    Thank you martha_camellia.

    Thread Starter muhammadwaqas

    (@muhammadwaqas)

    Thank you once again. I’m makring this topic as resolved ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hacking numbered pagination’ is closed to new replies.