-
-
Save maheshwaghmare/79c7eba02397e5d6741431ad770225e0 to your computer and use it in GitHub Desktop.
Get the function prefix_build_tree() from - https://gist.github.com/02b5611b48f1e7ce397cd191bd44a2cf - Read more at https://maheshwaghmare.com/?p=37686
This file contains 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 | |
function prefix_page_tree_markup( $page_id = 0 ) { | |
$pages = prefix_get_page_tree( $page_id ); | |
if( empty( $pages ) ) { | |
if( is_user_logged_in() ) { | |
echo '<p>No Post Found!</p>'; | |
} | |
return; | |
} | |
echo '<ul>'; | |
foreach( $pages as $page ) { | |
echo '<li><a href="'.$page['link'].'">'. $page['post_title'] . '</a>'; | |
if( ! empty( $page['children'] ) ) { | |
echo '<ol>'; | |
foreach( $page['children'] as $child_1 ) { | |
echo '<li><a href="'.$child_1['link'].'">'. $child_1['post_title'] . '</a>'; | |
if( ! empty( $child_1['children'] ) ) { | |
echo '<ol>'; | |
foreach( $child_1['children'] as $child_2 ) { | |
echo '<li><a href="'.$child_2['link'].'">'. $child_2['post_title'] . '</a>'; | |
if( ! empty( $child_2['children'] ) ) { | |
echo '<ol>'; | |
foreach( $child_2['children'] as $child_3 ) { | |
echo '<li><a href="'.$child_3['link'].'">'. $child_3['post_title'] . '</a>'; | |
echo '</li>'; | |
} | |
echo '</ol>'; | |
} | |
echo '</li>'; | |
} | |
echo '</ol>'; | |
} | |
echo '</li>'; | |
} | |
echo '</ol>'; | |
} | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment