Quantcast
Viewing all articles
Browse latest Browse all 134500

wp student on "Hacking numbered pagination"

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 all articles
Browse latest Browse all 134500

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>