Exclude Active Page

Hi there,

working on a project where i pull all the related pages to help with navigation.
however i would like to exclude the current active page from the list.

what would be the best way to do this? currently toying with this function:

<?php foreach($pages->children()->not($activePage)->visible() as $subpage): ?>
 <?php echo $subpage->title(); ?>
<?php endforeach ?>      

Thankful for advice.


1 Like

It depends on what pages you are trying to get, not() is probably the best option in your case. If you are trying to fetch siblings of a page, you can also set the $self parameter to false: https://getkirby.com/docs/cheatsheet/page/siblings

thanks for the response texnixe.

what would be the best way to indicate the current active page, for the not() filter?

the pages are children of β€˜Home’:

β€” Home
β€” 1
β€” 2
β€” 3



$pages = page('home')->children()->not($site->activePage());
foreach($pages as $p) {
  echo $p->title():


works like a charm. interesting to see that activePage() work within the function.

thanks again for the guidance.


1 Like

Hi, i don’t get how to apply the $self parameter to false on my code. Right now the current page is displaying on my list.

Here is my code:

<?php foreach ($projets = $page->siblings()->published() as $projet): ?>
  <?php snippet('projet-bloc', ['projet' => $projet]) ?>
<?php endforeach ?>
<?php foreach ($page->siblings(false)->published() as $projet): ?>
  <?php snippet('projet-bloc', ['projet' => $projet]) ?>
<?php endforeach ?>

oh thank you! I tested everything but this one.