ThemeShaper Forums » Power Blog

[closed]

Home link image instead of text?

(7 posts)
  • Started 12 years ago by thibotus01
  • Latest reply from thibotus01
  1. thibotus01
    Member

    Hi,

    In Power Blog child theme.

    That's the function to add a home link in the menu, but instead of text I'd like to replace it by an image. How could i specify this in the function?

    Thanks,

    // Adds a home link to your menu
    // http://codex.wordpress.org/Template_Tags/wp_page_menu
    function childtheme_menu_args($args) {
        $args = array(
            'show_home' => 'Home',
            'sort_column' => 'menu_order',
            'menu_class' => 'menu',
            'exclude' => '2', // Excluding pagess
            'echo' => true
        );
        return $args;
    }
    add_filter('wp_page_menu_args','childtheme_menu_args');
    Posted 12 years ago #
  2. best bet is via CSS...

    set a size for the link and set your image the background-image. then use text-indent: -9999px (something negative and ridiculously large) to basically ensure that it never appears on the screen.

    Posted 12 years ago #
  3. thibotus01
    Member

    Yes but I have to define a class for the home link, and I can't because the code is generated automatically by the function above.

    Posted 12 years ago #
  4. thibotus01
    Member

    Any idea?

    Posted 12 years ago #
  5. thibotus01
    Member

    // Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
    function thematic_add_menuhomeclass($liclass) {
    	return preg_replace('/ < li > /', '<li class="sf-menu-home">', $liclass, 1);
    } // end thematic_add_menuclass
    add_filter('wp_page_menu','thematic_add_menuhomeclass');

    Is that the suppose to work? (because it doesn't). I took it from the original code for the first UL class.

    Posted 12 years ago #
  6. Try this using an id instead of a class to account for the potential occurrence of the current-page-item class:

    function thematic_add_menuhomeclass($liclass) {
    	return preg_replace('/<li(.*?)>/', '<li id="home" $1>', $liclass, 1);
    } // end thematic_add_menuclass
    add_filter('wp_page_menu','thematic_add_menuhomeclass');

    -Gene

    Posted 12 years ago #
  7. thibotus01
    Member

    Yah it works :) thanks

    Posted 12 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.