Solution for unique page navigation in top navigation, sidebar
December 14, 2007 — lance_grigsbyWell, the folks at Wordpress tell me there’s no easy solution for creating an additional page widget to make it easy for a user on the backend to have unique page navigation in a top nav area and also in the sidebar (without rewriting the code for the page widget). You can read the forum here. However, this can still be done, but it will require tweaking some paramaters of the wp_list_pages() function.
In my previous post about creating a top nav bar, you can use the same code I provide to create your top navigation, but here’s how you’ll have to use it in the header.php file: In the theme editor, open the header.php file and scroll to the bottom of that document to find the <div id="header"> </div> code and paste the following code after it:
<ul id="topNav">
<?php wp_list_pages('exclude=7,8,9&title_li=' ); ?>
</ul>
The parameters 'exclude=7,8,9&title_li=' tell Wordpress to 1). exclude the pages you don’t want to show up in the top nav area, and to 2). not list the widget <h2> header by passing a null value to the 'title_li=' parameter. This appears to be the only way that you can have unique page navigation in a top navigation area and ALSO in the sidebar. When you want to exlcude pages from the top nav, you’ll have to list your own page IDs in the code provided; and of course, to exclude the pages that appear in the top nav from the sidebar page widget, all you have to do is use the widget interface to configure that widget to list only the pages you want.
Thanks to the moderators at Wordpress for helping me figure this out …