List pages and sub pages in footer
-
Hi all
I have a page structure like this.
Home About - Who we are - What we do - How we do it Work - Project 1 - Project 2 - Project 3 - Project 4
I would like to list them in the footer like this
<ul> <li>Home</li> </ul> <ul> <li>About</li> <li>Who we are</li> <li>What we do</li> <li>How we do it</li> </ul> <ul> <li>Work</li> <li>Project 1</li> <li>Project 2</li> <li>Project 3</li> <li>Project 4</li> </ul>
I found this in the Codex
<?php if(!$post->post_parent){ // will display the subpages of this top level page $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); } else{ if($post->ancestors) { // now you can get the the top ID of this page // wp is putting the ids DESC, thats why the top level ID is the last one $ancestors = get_post_ancestors($this_page); $children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0"); } } if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>
but it’s giving me something like this
<ul> <li class=""><a href="">Home</a></li> <li class=""><a href="">About</a> <ul class='children'> <li class=""><a href="">Who we are</a></li> <li class=""><a href="">What we do</a></li> <li class=""><a href="">How we do it</a></li> </ul> </li> <li class=""><a href="">Work</a> <ul class='children'> <li class=""><a href="">Project 1</a></li> <li class=""><a href="">Project 2</a></li> <li class=""><a href="">Project 3</a></li> <li class=""><a href="">Project 4</a></li> </ul> </li>
How can I get the structure I wanted.
Thanks in advance for any help.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘List pages and sub pages in footer’ is closed to new replies.