Created
July 25, 2017 13:05
-
-
Save nicomollet/91f6da31c918598aa935b03c230c2d01 to your computer and use it in GitHub Desktop.
Replace Home menu item by home icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace Home menu item by home icon | |
* | |
* @param $sorted_menu_items | |
* | |
* @return mixed | |
*/ | |
function homeicon_nav_menu_objects( $sorted_menu_items ) | |
{ | |
foreach ( $sorted_menu_items as $item ) { | |
if(untrailingslashit($item->url) == untrailingslashit(home_url())){ | |
$item->title = ''; | |
$item->attr_title = 'glyphicon-home'; | |
} | |
} | |
return $sorted_menu_items; | |
} | |
add_filter( 'wp_nav_menu_objects', 'homeicon_nav_menu_objects' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment