# Merge Collection of Pages

**URL:** <https://forum.getkirby.com/t/merge-collection-of-pages/766>\
**Category:** Questions\
**Tags:** v2\
**Created:** [April 10, 2015, 9:25pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766 "2015-04-10T21:25:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![twirx](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@twirx](https://forum.getkirby.com/u/twirx)\
**Post date:** [April 10, 2015, 9:25pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766/1 "2015-04-10T21:25:53Z")

</div>

I’d like to merge two or more collections of Kirby page objects. In Kirby 1 there was something like `Pages::merge($collection1, $collection2)`, but this doesn’t seem to work in Kirby 2.

Are there any alternative? Thanks in advance to anybody who might have an idea!

Till

---

<div class="post-metadata">

**Author:** ![walkerbox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/walkerbox/32/323_2.png) [@walkerbox](https://forum.getkirby.com/u/walkerbox)\
**Post date:** [April 10, 2015, 9:32pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766/2 "2015-04-10T21:32:30Z")

</div>

```
$pages->add($collection);
```

---

<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:** [April 10, 2015, 9:43pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766/3 "2015-04-10T21:43:23Z")

</div>

//Merge two collections

```auto
<?php 
  $exhibitions = $pages->find('exhibitions')->visible()->children()->filterB('now', 'noo');
  $news = $pages->findBy('news')->visible()->children();
  $homeflux = new Pages(array($exhibitions, $news));
?>

```

//Appending stuff to a collection:

```auto
<?php 
  $homeflux = new Pages();
  $homeflux->add($pages->find('exhibitions')->visible()->children()->filterBy('now', 'noo'));
  $homeflux->add( $pages->findBy('news')->visible()->children());
// etc...
?>

```

---

<div class="post-metadata">

**Author:** ![twirx](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@twirx](https://forum.getkirby.com/u/twirx)\
**Post date:** [April 11, 2015, 4:24pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766/4 "2015-04-11T16:24:06Z")

</div>

Thank you, @walkerbox and @texnixe! That did the trick!

---

<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, 5:17pm UTC](https://forum.getkirby.com/t/merge-collection-of-pages/766/5 "2025-02-06T17:17:31Z")

</div>


