WordPress List Pages

On previous post, I edited the header.php for including horizontal menu on listing main pages on this site. The code is as below:

42
43
44
45
46
47
48
49
  1. <div id="navmenu">
  2. <ul>
  3. <li><a href="<?php echo get_settings('home'); ?>">Home</a></li>
  4. <li><a href="blog">Blog</a></li>
  5. <li><a href="Gallery">Gallery</a></li>
  6. <li><a href="about">About</a></li>
  7. </ul>
  8. </div>

Now, I want it to be dynamically list all the main pages on this site in horizontal menu. The way to do is using wp_list_pages(); template tag. With this, I don’t have to manual edit the code if new page is added. Below are the new replacement code in header.php.

42
43
44
45
46
  1. <div id="navmenu">
  2. <ul>
  3. <?php wp_list_pages('depth=1&sort_column=menu_order&title_li='); ?>
  4. </ul>
  5. </div>

Related Posts

References

2 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">