Featured articles are only picked up if not paginated

I have the following definition of $articles:

  $articles = $page->children()->filter(function ($child) {
    return $child->translation(kirby()->language()->code())->exists();

  $articles   = $articles->paginate(6);
  $pagination = $articles->pagination();

  return compact('articles', 'tags', 'tag', 'pagination');

In a sidebar I want to display all pages that have the blueprint field featured = true:

<?php foreach ($articles as $article): ?>

      <?php if($article->featured()->toBool()): ?>

      <?php endif ?>

    <?php endforeach ?>

This works as long as all featured pages are on the current page but as soon as a featured page is on another page (let’s say on page 2 while I am on page 1) they don’t appear in the sidebar.
Why is that and how can I fix it?

I’d create another collection (note that I redefined your $articles collection, moving listed before the filter function:

$articles = $page->children()->listed()->filter(function ($child) {
    return $child->translation(kirby()->language()->code())->exists();
// this needs to come before you paginate
$featuredArticles = $articles->filterBy('featured', true);

// rest of code
return compact('articles', 'featuredArticles', 'tags', 'tag', 'pagination');

The if statement inside your sidebar loop is then no longer necessary.

You are incredible fast and helpful, thanks a lot!