ThemeShaper Forums » Thematic

[closed]

Home link in nav not working

(5 posts)
  • Started 5 years ago by hoopeys
  • Latest reply from DorinChill
  • This topic is resolved

Tags:

  1. hoopeys
    Member

    Hi there, I'm new to WordPress and Thematic, but liking it a lot so far. I'm struggling with adding the home button to the main navigation bar. I've looked through the tutorials and forum posts on it and it looks like I should have everything I need, but it is still not working. Maybe I missed something... here's the code from my functions.php file in my child theme:

    <?php
    // Adds Home link to navigation
    function sample_menu() {
        $menu = '<div id="menu"><ul>';
        if ( is_home() ) {
            $menu .= '<li class="current_page_item"><a href="';
        }
        else {
             $menu .= '<li><a href="';
        }
        $menu .= get_option('home') . '/" title="Home">Home</a></li>';
        $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages('title_li=&sort_column=menu_order&echo=0') );
        $menu .= "</ul></div>\n";
        echo $menu;
    }
    add_filter('globalnav_menu', 'sample_menu' );
    ?>

    Any ideas? Thanks in advance for the help.

    Posted 5 years ago #
  2. Change
    "add_filter('globalnav_menu', 'sample_menu' ); "
    in
    "add_filter('wp_page_menu', 'sample_menu' ); "

    that works fine !

    Posted 5 years ago #
  3. hoopeys
    Member

    Anthrax - thanks much that added the Home button to the menu. I noticed that when I made the change it removed all stylings for the menu class, because in the functions.php code, the div has id=menu rather than class=menu. I corrected the code and it works great now! Here's the updated code for those interested:

    <?php
    // Adds Home link to navgation
    function sample_menu() {
        $menu = '<div class="menu"><ul>';
        if ( is_home() ) {
            $menu .= '<li class="current_page_item"><a href="';
        }
        else {
             $menu .= '<li><a href="';
        }
        $menu .= get_option('home') . '/" title="Home">Home</a></li>';
        $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages('title_li=&sort_column=menu_order&echo=0') );
        $menu .= "</ul></div>\n";
        echo $menu;
    }
    add_filter('wp_page_menu', 'sample_menu' );
    
    ?>
    Posted 5 years ago #
  4. I've made an updated solution for this: http://forums.themeshaper.com/topic/how-to-add-a-home-link-to-your-child-theme-menu

    Posted 5 years ago #
  5. DorinChill
    Member

    it works but it ruins its aspect...thei look like a list now...

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.