Created
May 26, 2013 16:14
-
-
Save bugsysop/5653227 to your computer and use it in GitHub Desktop.
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
| /* | |
| <?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