WordPress Tips – Modifying your Pages menu

If your theme is set to display a list of your pages, the list should now contain links to both My New Home Page and Recent Posts.

default-menu

 

Here’s the code from our old menubar.php theme file:

<div class=”TopMenu”><a name=”top” id=”top”></a><ul><li><a href=”<?php echo get_option(’home’); ?>/”>Home </a></li><?php wp_list_pages(’depth=1&sort_column=menu_order&title_li=’ . __(”) . ” ); ?></ul></div>

To remove the (now redundant) Home link, simply delete:

<li><a href=”<?php echo get_option(’home’); ?>/”>Home </a></li>

There’s one more problem, right now our page links are in alphabetical order. Fortunately the sort_column parameter of the wp_list_pages function in our code is set to menu_order. That means we can adjust the menu order by editing the Page Order setting for our pages:

  1. Locate the page you want to change the Page Order setting for in the Manage>Pages subpanel and click Edit
  2. The Page Order setting is at the bottom of the right-hand column.
  3. If necessary click the + icon to expand the edit box and reveal the Page Order text box.
  4. Type a number into the Page Order text box. For our example we’ll order the pages:
    1. My New Home Page
    2. Recent Posts
    3. About

Pages with lower Page Order appear first in the menu. Pages with the same Page Order are sorted alphabetically. Our menu should now look like this:

new-menu

 

By default, newly created pages have a Page Order of zero which will put them at the front of your menu if you forget to change it.

You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.

Powered by WordPress | AT&T Cell Phones for Sale at iFreeCellPhones.com | Thanks to PalmPreBlog.com, MMORPGs and Online Shopping