WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

      <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>

I'm using this code to do it.

    <div id="footerLinks">
        $args = array(
            'sort_column' => 'menu_order',
            'parent' => 0,
        $pages = get_pages($args);
        foreach($pages as $page){
                        <a href="<?php echo $page->permalink; ?>"><?php echo $page->post_title;?> </a> 

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?

share|improve this question
While this question probably was in scope for both sites, please refrain from posting simultaneous duplicates on other SE network sites in the future. – Johannes Pille Mar 31 '13 at 11:55
up vote 3 down vote accepted

$page->post_parent is the ID of the parent page. So

get_permalink( $page->post_parent );

… should do it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.