I have a gallery with pagination on my website (On Point Window Treatment), but something is off. When I click next, it takes me to the homepage (even manually adding to the URL /page:2 takes home). The odd thing is that it works when I select a filter.
This is what my code looks like:
<div class="wrapper">
<?php
$projects = $page->children();
if($tag = param('tag')) {
$projects = $projects->filterBy('tags', $tag, ',');
}
$count = 0;
foreach($projects_pages = $projects->paginate(10) as $project) {
$count ++;
?>
<li <?php if($count % 5 == 1){ ?>class="large"<?php } ?> >
<a href="<?= $project->url() ?>">
<div class="image-wrapper">
<?php if($image = $project->cover()->toFile()): ?>
<?php if($count % 5 == 1): ?>
<img src="<?= $image->crop(1006, 768)->url() ?>" alt="">
<?php else: ?>
<img src="<?= $image->crop(1342, 1480)->url() ?>" alt="">
<?php endif ?>
<?php endif ?>
</div>
</a>
<div class="info">
<h3><?= html($project->title()) ?><br><?= html($project->subtitle()) ?></h3>
<div class="excerpt"><?= $project->text()->kt() ?></div>
<a href="<?= $project->url() ?>" class="btn dark arrow">Learn More <svg xmlns="http://www.w3.org/2000/svg" width="27.981" height="14.587" viewBox="0 0 27.981 14.587"><path id="Path_49" data-name="Path 49" d="M22,9a1,1,0,0,0,0,1.42l4.6,4.6H3.06a1,1,0,1,0,0,2H26.58L22,21.59A1,1,0,0,0,23.41,23l6.36-6.36a.88.88,0,0,0,0-1.27L23.42,9A1,1,0,0,0,22,9Z" transform="translate(-2.06 -8.704)" fill="#fff"/></svg></a>
</div>
</li>
<?php
}
?>
</div>
<div class="wrapper nav-wrapper">
<?php if ($projects_pages->pagination()->hasPages()): ?>
<nav class="pagination">
<?php if ($projects_pages->pagination()->hasNextPage()): ?>
<a class="next btn" href="<?= $projects_pages->pagination()->nextPageURL() ?>">
Next
</a>
<?php endif ?>
<?php if ($projects_pages->pagination()->hasPrevPage()): ?>
<a class="prev btn" href="<?= $projects_pages->pagination()->prevPageURL() ?>">
Previous
</a>
<?php endif ?>
</nav>
<?php endif ?>
</div>