Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Created May 26, 2013 21:34
Show Gist options
  • Select an option

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

Select an option

Save bugsysop/5654089 to your computer and use it in GitHub Desktop.
Anther funtion to list child page. Function to add in function.php
/* Loop
<?php while(get_child()): ?>
// links, img, custom fields
<?php endwhile; ?>
*/
/* Function */
function get_child($original='') {
if( ! Registry::has('page_original')) {
Registry::set('page_original', $original);
}
if( ! $pages = Registry::get('page_children')) {
$pages = Page::
where('status', '=', 'published')
->where('parent', '=', page_id())
->sort('id', 'desc')
->get();
Registry::set('page_children', $pages = new Items($pages));
}
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