Donc, ceci est mon code. Ce morceau de code me montre les titres de page enfant. Mais je fournis l'ID de la page parente. Y a-t-il un moyen de rendre cette dynamique? Je ne veux pas utiliser l'ID cuz alors sa statique ..
<?php
$childArgs = array(
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'child_of' => 127
);
$childList = get_pages($childArgs);
foreach ($childList as $child) { ?>
<ul class="menu-items menu-level-1 menu-count-5">
<li class="menu-item item-number-1 item-number-2 item-number-3 item-number-4 item-number-5 item-id-84283 item-odd item-page item-node item-alias-over-ons-de-winkel"><a href=""><?php echo $child->post_title; ?></a></li>
<?php } ?>
// le code correct
functions.php
function get_page_parent_id( $id ) {
$args = array(
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'child_of' => $id
);
$args = get_pages($args);
if(is_array($pages))
$pageID = $id;
else {
$pageID = wp_get_post_parent_id( $id );
}
return $pageID;
}
?>
page.php
<?php
$parentID = get_page_parent_id(get_the_ID());
$childArgs = array(
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'child_of' => $parentID
); ?>
<div class="subnav">
<h3 class="subnav-headline"><a href="/over-ons" class="c-dark"><?php echo get_the_title($parentID); ?></a></h3>
<ul class="menu-items menu-level-1 menu-count-5">
<?php $pages = get_pages($childArgs);
foreach($pages as $page ) { ?>
<li class="menu-item item-number-2 item-id-84286 item-even item-page item-node item-alias-over-ons-geschiedenis-leonidas"><a href="<?php echo get_the_permalink($page);?>"><?php echo $page->post_title;?></a></li>
<?php } ?>
</ul>
</div>