Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'GET') 
{
    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" >

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

    </form>

            <?php 
            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

 
discard

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

Browse other questions tagged or ask your own question.