delarge
10/7/2019 - 12:25 PM

WP child page sub nav

<?php

global $post;     // if outside the loop
$children = get_pages( array( 'child_of' => $post->ID ) );
   if ( is_page() && ($post->post_parent || count( $children ) > 0  )) :
		// check which ID to compare against

			if (count( $children ) > 0) { // is parent
				$post_id_compare = $post->ID;
			} else {
			$post_id_compare = wp_get_post_parent_id( $post->ID );
			}


	 ?>

<div class="sub-page-nav">
<div class="holder">
<ul class="sub-page-nav">
	<?php wp_list_pages( array(
		'child_of' => $post_id_compare,
			'title_li' => ''
	) ); ?>
</ul>
</div>
</div>

<?php endif; ?>