WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working to develop this type of pagination: here

I am taking values and displaying them on same page and my code snippet is below and couldn't make it why it is not working.

    global $paged;
    if(empty($paged)) $paged = 1;
    else { $paged = $_GET['paged']; }
        if(isset($paged) && is_numeric($paged) && ($paged <= $pages) && ($paged >= 1))              //validation
            if($pages == '')
                global $wp_query;
                $pages = $wp_query->max_num_pages;
                    if(!$pages) $pages = 1;

            if(1 != $pages)
            { ?>

    <form action="#" method="get" >

            <input type="text" name="paged" value="<?php echo $paged; ?>">
            of <?php echo $pages; ?>
            <input type="submit">


            if($paged > 1) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Prev Page</a>";
            if ($paged < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next Page &rsaquo;</a>"; 


Please suggest.

share|improve this question
can anyone suggest something? – 10wtaylor Mar 20 '13 at 12:41
Can you please describe how it is not working? Which part is not doing what you expect it to do? And what is actually happening? – David Gard Mar 20 '13 at 12:55
@DavidGard I have added this snip in index.php after the loop, but I am not able to see anything. I think maybe the way code works is wrong that I developed. – 10wtaylor Mar 21 '13 at 8:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.