Created
May 26, 2013 21:34
-
-
Save bugsysop/5654089 to your computer and use it in GitHub Desktop.
Anther funtion to list child page. Function to add in function.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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