Jump to content

Pagination not working


Liam88
 Share

Recommended Posts

Hoping someone can help.

I have pagination all set up with the usual steps:

  1. Make sure "markuppagernav" is installed
  2. Allow page numbers on the template
  3. Create a page query that selects a limited number of items.
  4. renderpager the items query.
<?php namespace ProcessWire;
$all = $page->children("template='blog-post', sort=-published");
$featured = $all->find("limit=4, check_featured!={$page->check_featured}");
$items = $all->find("limit=6");
?>

I have more than 6 posts to ensure it would show.

<?php
  echo $items->renderPager([
        'listMarkup' => '<nav aria-label="navigation"><ul class="pagination">{out}</ul></nav>',
        'itemMarkup' => '<li class="page-item {class}">{out}</li>',
        'linkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentLinkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentItemClass' => "active"
]);
?>

Then the above at the bottom of the page.

As mentioned the page numbers are enabled:

image.thumb.png.5b9a4f90f86ed70cab837e909525bf06.png

If I manually add in example.com/blog/page2/ then I just get the same output like example.com/blog/

Where am I going wrong?

TIA

Link to comment
Share on other sites

2 hours ago, 3fingers said:
$featured = $all->find("limit=4, check_featured!={$page->check_featured}"); // Just 4 results here
$items = $all->find("limit=6"); // Cannot be 6 here

Spot the mistake?

Hi,

Thank you for the reply

I get what you are thinking but I have the $all rule to then push into the two queries and neither $featured or $items reference each other.

The pagination is only referencing the $items which are the main posts below. I have put an image below to show the layout which may help.

Also, just to say I have removed the $featured query and the block above the breadcrumb and pagination still doesn't work. I have also removed the limit on $featured and use a count instead.

Above the breadcrumb is $featured and below is $items

image.thumb.png.c0f4e89df6c3db160de54d68a3a96291.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...