WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Top Navigation Bar Hack (8 posts)

  1. lcf
    Member
    Posted 9 years ago #

    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/

  2. XeroCool
    Member
    Posted 9 years ago #

    Nice hack! :)

  3. Root
    Member
    Posted 9 years ago #

    This looks handy for default users. If a guy has more pages than are going to be linked from the hnav - what happens then ?

  4. lcf
    Member
    Posted 9 years ago #

    @Root: I will write a navigation bar plugin then ;)

  5. Denis de Bernardy
    Member
    Posted 9 years ago #

    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 menus

  6. brente
    Member
    Posted 9 years ago #

    This 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.

  7. moshu
    Member
    Posted 9 years ago #

    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.wordpress.org/Template_Tags/wp_list_pages

  8. Denis de Bernardy
    Member
    Posted 9 years ago #

    There 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 links

    e.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.

Topic Closed

This topic has been closed to new replies.

About this Topic