ThemeShaper Forums » Thematic

help with functions.php - home link not working

(7 posts)
  • Started 10 years ago by BrightBold
  • Latest reply from Sebastian
  • This topic is resolved
  1. Well if you guys aren't sick of me yet, I have another question. The "show home link on the menu" function that I copied and pasted into my functions.php doesn't seem to have any effect. My other two copy-past functions (favicon and conditional stylesheets) work great. I don't really know PHP so any help anyone can offer would be great.

    Here's what my functions.php looks like:

    <?php
    // Adds Home link to navgation
    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</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('sandbox_menu', 'sample_menu' );
    
    // Uses child theme favicon
    function childtheme_favicon() { ?>
        <link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.ico" />
    <?php }
    
    add_action('wp_head', 'childtheme_favicon');
    
    // Adds conditional stylesheets
    function childtheme_iefix() { ?>
        <!--[if lt IE 8]>
    	<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/ie.css" />
        <![endif]-->
    <?php }
    
    add_action('wp_head', 'childtheme_iefix');
    ?>

    My site (in development) is at http://flasta.org/wp/

    Thanks for your help. This is probably some newbie error (failure to properly cut and paste???) but I can't figure it out.

    Posted 10 years ago #
  2. Looks like I have to update some tutorials! sandbox_menu has changed to globalnav_menu with version 0.7.

    Posted 10 years ago #
  3. Thanks! That's the ticket!

    Posted 10 years ago #
  4. burgundydurango
    Member

    oops, nevermind...

    Posted 10 years ago #
  5. Sebastian
    Member

    Hi there,

    I have a small question about the home-nav-link and would be very happy for your help (I'm an newby and php-analphabet): I copied the link above (use the old version with sandbox_menu), and it works well with firefox. But IE makes me cry: The home-link seems to be outside the ordinary ul, so
    1. the position is not in the center but close to the right, although the other links have a padding of 5 px to the left and the right,
    2. the padding to the bottom is extreemly big, seems as it produces a break and then continues with the ordinary ul. Has anybody a clue what could be wrong?
    Thanks a lot
    Sebastian

    Posted 10 years ago #
  6. Can you give us a link?

    And this may not solve your problem, but I noticed in the code above (which I lifted from Ian's site - I don't want to take credit for being able to write any PHP!) that the anchor link isn't closed. So change

    $menu .= get_option('home') . '/" title="Home">Home</li>';

    to

    $menu .= get_option('home') . '/" title="Home">Home</a></li>';

    It's possible that IE could be doing something weird because the tag wasn't closed, and that could be messing up your layout.

    Posted 10 years ago #
  7. Sebastian
    Member

    Hello Brightbold!

    thank you for your answer and your solution, I opened a new thread (http://forums.themeshaper.com/topic/some-problems-with-internet-explorer), because there were more problems with the internet-explorer, but I solved them all now. The missing /a was the right bug, if you close it, it runs fine! Thank you for your help!

    Sebastian

    Posted 10 years ago #

RSS feed for this topic

Reply

You must log in to post.