← Design & Development Blog
December 19, 2012

Replace Navigation Text with Icon Font

Looking to replace a navigation item with an icon font in WordPress? This little snippet placed in functions.php will do just that:


add_filter( 'wp_nav_menu', 'my_page_menu_link_names' );

function my_page_menu_link_names( $menu ) {

    $menu = str_replace( 'Your Nav Text', '<i class="icon-example"><span>Example</span></i>', $menu );

    
    return $menu;
}

Replace ‘Home’ and the icon font code with what ever your navigation item is. Be sure to hide the span using one of these hiding techniques from CSS Tricks.

Tagged
development
WordPress
WordPress Development