WordPress Top Navigation Bar Hack
-
What it does?
Add a navigation bar under template header image. The navigation bar has a tab that link to blog URL and auto add WordPress ‘pages’ link tabs.Link: http://www.liewcf.com/blog/archives/2005/05/wordpress-navigation-bar/
-
Nice hack! 🙂
This looks handy for default users. If a guy has more pages than are going to be linked from the hnav – what happens then ?
@root: I will write a navigation bar plugin then 😉
What would really be cool would be a navbar manager plugin with:
– the three relevant template tags for header nav, sidebar nav, footer nav
– an admin menu to add resources (e.g. pages, cats, links…) to the nav menus, including changing their order (independant from a nav menu to another), their navbar title (idem), and sub menusThis is a great top nav hack. But, if you have pages with sub-pages underneath, it breaks all over the place.
But I emailed the author for a fix for this, and he sent me this code, which only shows the 1st level page titles.
Find this code:
<?php wp_list_pages('title_li='); ?>Then replace it with:
<?php wp_list_pages('depth=1&title_li='); ?>The depth is to set how many level of pages to be displayed in the
list. Enjoy.With all due respect to the author – you could have found that info by reading about the relevant template tag in the Codex:
http://codex.ww.wp.xz.cn/Template_Tags/wp_list_pagesThere is something much more powerful when it comes to creating a nav bar:
http://www.semiologic.com/projects/sem-theme/
Follow these simple steps:
1. Copy the config.php file from one of the bundled themes and drop it — edited as necessary — into your theme’s directory.
2. Activate the Semiologic CMS plugin
3. Call sem_header_nav() and sem_footer_nav() in your template.
These will populate your nav bars with the best match between:
– internal pages
– categories
– arbitrary linkse.g.:
$sem_header_nav[‘Home’] = get_settings(‘home’);
$sem_header_nav[‘Blog’] = ‘blog’;
$sem_header_nav[‘Gallery’] = ‘gallery’;
$sem_header_nav[‘Links’] = ‘links’;
$sem_header_nav[‘About’] = ‘about’;
$sem_header_nav[‘Contact’] = ‘contact’;
$sem_header_nav[‘Somewhere’] = ‘http://wherever.com’;and calling sem_header_nav populates your header nav as appropriate.
The topic ‘WordPress Top Navigation Bar Hack’ is closed to new replies.