• Hi,

    I’m currently running a custom theme that has a separate ‘navigation’ in the sidebar of my pages. The nav is listing all correlated child pages correctly, but fails to correctly order child pages of child pages . (see attached link)

    https://s24.postimg.org/q6opvsd11/image.jpg

    “Career Inquiry” and “Testimonials” are both child pages of “Careers” but are displaying ABOVE the parent page instead of BELOW as I’d like. Here’s what I’m using in my functions.php

    function pfp_get_child_pages($id){
    	global $post;     // if outside the loop
    	$parent = '';
    	if ( is_page() && $post->post_parent ) {
    		$parent = $post->post_parent;
    	}else {
    		$parent = $id;
    	}
    
    	$pfp_wp_query = new WP_Query();
    	$all_wp_pages = $pfp_wp_query->query(array('post_type' => 'page','posts_per_page' => -1));
    	$listpage = get_page_children($parent,$all_wp_pages);
    	if(!empty($listpage) && $listpage != ''):
    	$listpage = array_reverse($listpage);
    	?>
    	<ul>
    		<?php foreach($listpage as $l):?>
    		<li><a href="<?php echo get_permalink($l->ID);?>" <?php echo ($id == $l->ID) ? 'class="active"' : '';?>><?php echo $l->post_title;?></a></li>
    		<?php endforeach;?>
    	</ul>
    	<?php
    	endif;
    }

    My php isn’t too great but I manage. Any help is appreciated!

  • The topic ‘Side Navigation Child Page Order’ is closed to new replies.