固定ページ 特定のスラッグを親に持つ記事の表示 wordpress



/*
	固定ページ 特定のスラッグを親に持つ記事の表示
*/
	if ( $post->ancestors ) {
		foreach ( $post->ancestors as $post_anc_id ) {
			$post_id = $post_anc_id;
		} // foreach($post->ancestors as $post_anc_id){
	} else {
		$post_id = $post->ID;
	} // if($post->ancestors){

	if ( $post_id ) {
		$children = wp_list_pages( 'title_li=&child_of=' . $post_id . '&echo=0' );
		if ( $children ) { ?>
			<aside class="widget widget_child_page widget_link_list">
			<nav class="localNav">
			<h1 class="subSection-title"><a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>"><?php echo get_the_title( $post_id ); ?></a></h1>
			<ul>
			<?php  echo $children; ?>
			</ul>
			</nav>
			</aside>
		<?php } // if ($children)
	} // if ($post_id)
?>