I know this is going to be simple but I can’t work it out.
I want to create a nav in the footer listing each page and it’s child pages.
It will look something like this
<ul>
<li><a href="parent.html">Parent</a></li>
<li><a href="childone.html">Child One</a></li>
<li><a href="childtwo.html">Child Two</a></li>
<li><a href="childthree.html">Child Three</a></li>
</ul>
I’m using this code to do it.
<div id="footerLinks">
<?php
$args = array(
'sort_column' => 'menu_order',
'parent' => 0,
);
$pages = get_pages($args);
foreach($pages as $page){
?>
<ul>
<li>
<a href="<?php echo $page->permalink; ?>"><?php echo $page->post_title;?> </a>
</li>
<?php
wp_list_pages('title_li=&depth=1&child_of='.$page->ID.'');
?>
</ul>
<?php
}
?>
</div>
My problem is getting the permalink to the parent page.
<a href="<?php echo $page->permalink; ?>"><?php echo $page->post_title;?> </a>
How do I get the permalink in this situation?
$page->post_parent
is the ID of the parent page. So⦠should do it.