Pagination does not count

Hi guys,

I’m trying to get my pagination to work, but something seems to be wrong
It counts the number of pages but it does not increment. It always displays 1/ …

								<?php
								echo ($count + 1) . " / " . $page->children()->visible()->paginate(10)->count();
								$count++; 
								?>

Maybe you have an idea what might be wrong?

What are you trying to there? Could you please post the code in context, not just that snippet?

	<?php $articles = $page->children()->visible()->flip()->paginate(10) ?>
.
.
.
.
		
<?php if($articles->pagination()->hasPages()): ?>
			<nav role="navigation">
				<div class="columns columns-3 row padding-top--2rem padding-bottom--2rem">
					<div class="column text-align--center">
						<?php if($articles->pagination()->hasNextPage()): ?>
							<h3><a class="next no--underline" href="<?php echo $articles->pagination()->nextPageURL() ?>">older</a></h3>
						<?php endif ?>					
					</div>
					<div class="column text-align--center">
						<h3>
							<?php
							echo ($count + 1) . " / " . $page->children()->visible()->paginate(10)->count();
							$count++; 
							?>
						</h3>
					</div>

					<div class="column text-align--center">
						<?php if($articles->pagination()->hasPrevPage()): ?>
							<h3><a class="prev no--underline" href="<?php echo $articles->pagination()->prevPageURL() ?>">newer</a></h3>
						<?php endif ?>				
					</div>
				</div>
			</nav>
		<?php endif ?>

I’d like to have a blog navigation with an incrementing number pagination in the middle.

If I get you right, you want something like this:

<?php 
$articles = $page->children()->visible()->flip()->paginate(10);
$pagination = $articles->pagination();
?>

<?php if($pagination->hasPages()): ?>
  <nav role="navigation">
    <div class="columns columns-3 row padding-top--2rem padding-bottom--2rem">
      <div class="column text-align--center">
        <?php if($articles->pagination()->hasNextPage()): ?>
          <h3><a class="next no--underline" href="<?php echo $pagination->nextPageURL() ?>">older</a></h3>
        <?php endif ?>
      </div>
      <div class="column text-align--center">
	    <h3><?php echo $pagination->page() . " / " . $pagination->countPages();?></h3>
      </div>

      <div class="column text-align--center">
	    <?php if($pagination->hasPrevPage()): ?>
	      <h3><a class="prev no--underline" href="<?php echo $pagination->prevPageURL() ?>">newer</a></h3>
	    <?php endif ?>
      </div>
    </div>
  </nav>
<?php endif ?>

If instead you want a range pagination, checkout this cookbook recipe.

That has been exactly what i wanted to do :slight_smile: Thank you a lot