The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Pagination dots …. between numbers

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #33123

    Hi all,

    how to make Pagination dots …. between numbers

    Like 1 2 3 …. 10 11 12

    Thanx in advance


    I assume you mean for page links as in a archive of blog posts? or just an array of numbers? Either way the concept would be similar, you would need to test where in the array you’re outputting you are, and based on the results output the ellipsis.

    $numbers = array(1,2,3,4,5,6,7,8,9,10,11,12);
    $output = '';
    $counter = 1;
    foreach ($numbers as $number){

    if($counter == 4){
    $output .= ' ...';
    }elseif($counter < 4 || $counter > (count($numbers) -3)){
    $output .= ' ' . $number;

    That should give you the results in your example, if you were to do it with pages and links you would replace the simple array with an array of the pages you need to link to and probably output the counter wrapped by an anchor tag with the link from the array, I hope this was helpful.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.