1

I have a custom plugin which have lots of table. that's why i need a proper pagination. Now i have a pagination but it show all 1 to 80 serially. Here is that code for pagination.

<?php

echo '<div id="pager">Page : <div class="btn-group">';
while( $loopLimit != $loopStart )
{
    echo '<a class="btn" href="admin.php?page=wp-glossary&requireTab=viewDelEditWord&totalItems='.$totalItems.'&currentPage='.$loopStart.'&orderByWord='.$_REQUEST["orderByWord"].'"';
    if ($loopStart == $currentPage) {echo ' id="activeParer"';}
    echo '>'.$loopStart.'</a>';
    $loopStart ++ ;
}
echo '</div></div>';

?>

Here is present pegination view: enter image description here

I want 1 2 3 4....10 11 12 like this. how i change this. Any idea?

1 Answer 1

0

Please try following code. and let me know if any.

    echo '<div id="pager">Page : <div class="btn-group">';
$loopStart = 1;
$currentPage = 4;
$loopLimit = 100;
$start_number_diplay = 5; // Number where you display in paganation in start and end.
$middle_number_diplay = 3;
$i = $j = 1; $total_pagination_display = 10;
while( $loopLimit != $loopStart )
{
    if( ($loopStart == ($start_number_diplay+1))  || ($total_pagination_display == $j)) {
        echo '<a class="btn" >...</a>';
        $j++;

    }

    echo '<a class="btn" href=""';
    if ($loopStart == $currentPage) {
        echo ' id="activeParer"';
    }
    if(($loopStart <= $start_number_diplay) ) {

        echo '>'.$loopStart.' </a>';
        $j++;

    }
    else if( (($loopStart%10) == 0) && ($i <= $middle_number_diplay) ) {
        echo '>'.$loopStart.' </a>';
        $i++;
        $j++;
    }
    $loopStart ++ ;

}
echo '</div></div>';
2
  • Thanks for Reply. it doesn't work properly. After add this code it look like this image: db.tt/HecxIV7B But i want stander pagination like this: db.tt/bgG0wVBg Please give me a best process. Thanks again.
    – mrhossen
    Jan 10, 2014 at 14:21
  • @mrhossen Please check updated code, I made just only example code. Please change it with your suitable code. Jan 11, 2014 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.