# Sorting pages in section

**URL:** <https://forum.getkirby.com/t/sorting-pages-in-section/15477>\
**Category:** Questions\
**Tags:** v3\
**Created:** [September 2, 2019, 12:01pm UTC](https://forum.getkirby.com/t/sorting-pages-in-section/15477 "2019-09-02T12:01:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nilshoerrmann](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nilshoerrmann/32/6005_2.png) [@nilshoerrmann](https://forum.getkirby.com/u/nilshoerrmann)\
**Post date:** [September 2, 2019, 12:01pm UTC](https://forum.getkirby.com/t/sorting-pages-in-section/15477/1 "2019-09-02T12:01:07Z")

</div>

I’m using a [pagesdisplay section](https://github.com/rasteiner/k3-pagesdisplay-section) to show a filtered and sorted list of pages in the panel. I’m using this query:

```auto
query: page.kitajahr

```

And this custom page method:

```auto
public function kitajahr()
{
    $year = date('Y');

    if (date('n') < 8) {
        $year--;
    }

    $start = date($year . '-08-01');
    $end = date($year + 1 . '-07-31');

    return $this->children()
        ->filterBy('date', '>=', $start)
        ->filterBy('date', '<=', $end)
        ->sortBy('date', 'desc');
}

```

This throws an error in the panel:

> Call to a member function `title()` on `null`

```json
{"status":"error","exception":"Error","message":"Call to a member function title() on null","file":"site\/models\/meal.php","line":8,"code":500,"route":"pages\/([a-zA-Z0-9\\.\\-_%= \\+\\@\\(\\)

```

If I remove the sorting it works on the first page. But as soon as I navigate to another but the first page, I get the error again.

Any ideas why this is happening?

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [September 2, 2019, 12:07pm UTC](https://forum.getkirby.com/t/sorting-pages-in-section/15477/2 "2019-09-02T12:07:32Z")

</div>

What is the content of `site/models/meal.php` on line 8?

---

<div class="post-metadata">

**Author:** ![nilshoerrmann](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nilshoerrmann/32/6005_2.png) [@nilshoerrmann](https://forum.getkirby.com/u/nilshoerrmann)\
**Post date:** [September 2, 2019, 12:14pm UTC](https://forum.getkirby.com/t/sorting-pages-in-section/15477/4 "2019-09-02T12:14:43Z")

</div>

Ah, that was the question I needed. I looked at the wrong file the whole time `meal` not `meals`. Found the issue (it was an empty title). Thanks!
