JSFiddle - React, Tailwind, and code Playground

by Drath

JavaScript

<?php
global $post;
$ancestors = get_post_ancestors($post->ID);
$parent = $ancestors[0];

if ($parent) {
    //Child
    echo wp_list_pages("title_li=&include=".$parent."&echo=0");
    $children = wp_list_pages("title_li=&child_of=".$parent."&echo=0");
} else {
    //Parent
    echo wp_list_pages("title_li=&include=".get_the_ID()."&echo=0");
    $children = wp_list_pages("title_li=&child_of=".get_the_ID()."&echo=0");
}

if ($children) {
    echo $children;
} 
?>