madeinthearcade
2/23/2017 - 10:52 AM

Show a parent's children pages. On children pages, show siblings.

Show a parent's children pages. On children pages, show siblings.

					<?php
					if ( $post->post_parent ) {
					    $children = wp_list_pages( array(
					        'title_li' => '',
					        'child_of' => $post->post_parent,
					        'echo'     => 0
					    ) );
					} else {
					    $children = wp_list_pages( array(
					        'title_li' => '',
					        'child_of' => $post->ID,
					        'echo'     => 0
					    ) );
					}
					if ( $children ) : ?>
						<h3 class="blue">
							<?php echo get_the_title( $post->post_parent ); ?>
						</h3>
					    <ul class="sidebox-list">
					        <?php echo $children; ?>
					    </ul>
					<?php endif; ?>
						<?php
						$args = array(
							'post_type'      => 'page',
							'posts_per_page' => -1,
							'post_parent'    => $post->ID,
							'order'          => 'ASC',
							'orderby'        => 'menu_order'
						);

						$parent = new WP_Query( $args );

						if ( $parent->have_posts() ) : ?>