Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Created May 26, 2013 16:14
Show Gist options
  • Select an option

  • Save bugsysop/5653227 to your computer and use it in GitHub Desktop.

Select an option

Save bugsysop/5653227 to your computer and use it in GitHub Desktop.
List child page. Function to add in function.php
/*
<?php while(mytheme_page_children()): ?>
<?php echo page_title(); ?>
<?php endwhile; ?>
*/
function mytheme_page_children() {
if( ! Registry::has('page_original')) {
Registry::set('page_original', $original);
}
if( ! $pages = Registry::get('page_children')) {
$query = Page::where('status', '=', 'published')->where('parent', '=', page_id())->get();
Registry::set('page_children', $pages = new Items($query->get()));
}
if($result = $pages->valid()) {
Registry::set('page', $pages->current());
$pages->next();
}
else {
$pages->rewind();
Registry::set('page', Registry::get('page_original'));
Registry::set('page_original', false);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment