Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 1.08 KB

PAGES-METHODS.md

File metadata and controls

53 lines (37 loc) · 1.08 KB

Pages Methods

You don't need to use the pages methods. They are pure helper functions.

$pages->published()

Filter the result to only contain published pages.

foreach( $pages->published() as $item ) {
  echo $item->title() . ' ' . $item->getStatus() . '<br>';
}

$pages->unpublished()

Filter the result to only contain unpublished pages.

foreach( $pages->unpublished() as $item ) {
  echo $item->title() . ' ' . $item->getStatus() . '<br>';
}

$pages->private()

Filter the result to only contain private pages.

foreach( $pages->private() as $item ) {
  echo $item->title() . ' ' . $item->getStatus() . '<br>';
}

$pages->privatePublished()

Filter the result to contain private and published pages.

foreach( $pages->privatePublished() as $item ) {
  echo $item->title() . ' ' . $item->getStatus() . '<br>';
}

Loop only if logged in

$collection = ( ! site()->user() ) ? $pages->published() : $pages->privatePublished();

foreach( $collection as $item ) {
  echo $item->title() . ' ' . $item->getStatus() . '<br>';
}