Skip to content

Instantly share code, notes, and snippets.

@tommarute
Last active February 4, 2020 12:26
Show Gist options
  • Save tommarute/98afacab87a0db6d84d6920e44e62c87 to your computer and use it in GitHub Desktop.
Save tommarute/98afacab87a0db6d84d6920e44e62c87 to your computer and use it in GitHub Desktop.
<?php
$parentId = get_the_ID();
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $parentId,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$posts = get_posts($args);
if ($posts):
foreach ($posts as $post):
$grandchildren = get_page_children($post->ID, $posts);
if ($grandchildren):
foreach ($grandchildren as $grandchild):
?>
<li class="grandchild-link">
<a href="<?php get_permalink($grandchild->ID)?>"><?php $grandchild->post_title;?></a><!-- 記事タイトル表示 -->
</li>
<?php
endforeach;
endif;
endforeach;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment