# Pagination in kirby documentation not working

**URL:** <https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 25, 2016, 11:07am UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683 "2016-03-25T11:07:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidjwall](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@davidjwall](https://forum.getkirby.com/u/davidjwall)\
**Post date:** [March 25, 2016, 11:07am UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683/1 "2016-03-25T11:07:30Z")

</div>

I’ve been over this a bunch of times now. I’m following the pagination documented on the kirby website but when i skip to my second page it shows items from the first page.

This is my code:

```auto
                    <div class="col-md-1 content-block"></div>
                    	<div class="col-md-10 content-block">
                            <ul class="events-list">
                            <?php 
                            $list = $page->children()->paginate(3);
                            $pagination = $list->pagination();
                            $i = 0;
                                foreach($list as $item): ?>
                                    <li class="event-list-item">
                                        <?php $calendar = $page->children()->nth($i)->calendar()->yaml();
                                        foreach($calendar as $calendarEntry): ?>
                                                <span class="event-date">
                                                    <span class="date">
                                                        <?php 
                                                            $eventday=strtotime($calendarEntry['_begin_date']);
                                                            echo date('j',$eventday);  
                                                        ?>
                                                    </span>
                                                    <span class="month">
                                                        <?php 
                                                            $eventmonth=strtotime($calendarEntry['_begin_date']);
                                                            echo date('M',$eventmonth);  
                                                        ?>
                                                    </span>
                                                    <span class="year">
                                                        <?php 
                                                            $eventmonth=strtotime($calendarEntry['_begin_date']);
                                                            echo date('Y',$eventmonth);  
                                                        ?>
                                                    </span>
                                                </span>
                                                <div class="event-list-cont">
                                                    <span class="meta-data">Starts:
                                                        <?php $eventday=strtotime($calendarEntry['_begin_date']);
                                                        echo date('l',$eventday); ?>, 
                                                        <?php $eventstarttime=strtotime($calendarEntry['_begin_time']);
                                                        echo date('g:i A',$eventstarttime); $eventday=strtotime($calendarEntry['_end_date']);
                                                        if ($eventday){ ?>
                                                            | Finishes: <?php echo date('l',$eventday); ?>,
                                                            <?php } ?>
                                                        <?php $eventendtime=strtotime($calendarEntry['_end_time']);
                                                        if($eventendtime) {
                                                            echo date('g:i A',$eventendtime);
                                                            } ?></span>
                                                    <h4 class="post-title"><a href="<?php echo page('events')->children()->nth($i)->url(); ?>"><?php echo $calendarEntry['eventname'] ?></a></h4>
                                                    <p>
                                                        <?php echo page('events')->children()->nth($i)->eventwriteup()->excerpt(250); ?> <a href="<?php echo page('events')->children()->nth($i)->url(); ?>">read&nbsp;more&nbsp;→</a>
                                                    </p>
                                                </div>
                                            <?php $i++; ?>
                                        <?php endforeach; ?>
                                    </li>
                                <?php endforeach; ?>
    
                            </ul>
                            <!-- Page Pagination -->

                            <nav>
                                <ul class="pagination pagination-lg">

                                    <?php if($pagination->hasPrevPage()): ?>
                                    <li>
                                        <a href="<?php echo $pagination->prevPageURL() ?>">&larr;</a></li>
                                        <?php else: ?>
                                        <li><span>&larr;</span></li>
                                        <?php endif ?>
                                    
                                    <?php foreach($pagination->range(10) as $r): ?>
                                        <li><a<?php if($pagination->page() == $r) echo ' class="active"' ?> href="<?php echo $pagination->pageURL($r) ?>"><?php echo $r ?></a></li>
                                    <?php endforeach ?>

                                    <?php if($pagination->hasNextPage()): ?>
                                    <li class="last"><a href="<?php echo $pagination->nextPageURL() ?>">&rarr;</a></li>
                                    <?php else: ?>
                                    <li class="last"><span>&rarr;</span></li>
                                    <?php endif ?>
                                </ul>
                            </nav>
                        </div>

```

Does the Issue have something to do with calling the loop for the calendar plugin data within the events-list loop? Any advice much appreciated

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [March 25, 2016, 11:16am UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683/2 "2016-03-25T11:16:16Z")

</div>

The issue is this line:

```auto
$calendar = $page->children()->nth($i)->calendar()->yaml()

```

By using this line, you ignore pagination and manually get the nth child.  
Instead, simply use the following:

```auto
$calendar = $item->calendar()->yaml()

```

The same applies to the other instances where you use `nth()`.

---

<div class="post-metadata">

**Author:** ![davidjwall](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@davidjwall](https://forum.getkirby.com/u/davidjwall)\
**Post date:** [March 25, 2016, 12:44pm UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683/3 "2016-03-25T12:44:17Z")

</div>

> [@lukasbestle](#):
>
> $calendar = $item-\>calendar()-\>yaml()

Thank you so much! That was the last major issue i have with my site. This forum has been a great help. Learned a few things as well 🙂

I’ve removed all the $i from this code now. Now i see there’s no need for it at all.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 25, 2016, 1:19pm UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683/4 "2016-03-25T13:19:38Z")

</div>

Hi David,

next time, instead of creating the same topic again, could you pls. just edit the original post or add something to it to push it up again, pls.? That would help to keep the forum tidy 🙂, thank you.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:59pm UTC](https://forum.getkirby.com/t/pagination-in-kirby-documentation-not-working/3683/5 "2025-02-06T16:59:56Z")

</div>

Archived on February 6, 2025, 4:59pm UTC


