# Pagination for Comments

**URL:** <https://discourse.cakephp.org/t/pagination-for-comments/9729>\
**Category:** Need Help\
**Created:** [September 21, 2021, 10:08pm UTC](https://discourse.cakephp.org/t/pagination-for-comments/9729 "2021-09-21T22:08:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 26, 2021, 4:23am UTC](https://discourse.cakephp.org/t/pagination-for-comments/9729/4 "2021-09-26T04:23:20Z")

</div>

In your first example, you’re passing a query in to `paginate`, which is overriding the limit with its own default. In the second case, you’re explicitly telling `paginate` what the limit should be. So:

```auto
$query = $this->Comments
    ->find()
    ->contain([‘Users’, ‘Users.Profiles’])
    ->where([‘article_id =’ => $id]);
$comments = $this->paginate($query, ['limit' => 5]);

```

should work as expected. (You can do it all without the `$query` variable; I separated it to make it clearer what is doing what.)

---

_[View the full topic](https://discourse.cakephp.org/t/pagination-for-comments/9729)._
