Created
June 17, 2015 12:36
-
-
Save neverything/c30924b53c926b3ab45b to your computer and use it in GitHub Desktop.
This function adds a logo as a first menu item.
This file contains 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 | |
function ict_bz_add_logo_to_menu( $items, $args, $logo_path = 'https://placekitten.com/g/150/150', $menu_locations = array( 'primary' ) ) { | |
if ( in_array( $args->theme_location, $menu_locations ) ) { | |
$logo_item = sprintf( | |
'<li class="menu_item menu_item_custom menu_item_logo"><a href="%s"><img src="%s"></a></li>', | |
get_home_url(), | |
$logo_path | |
); | |
$items = $logo_item . $items; | |
} | |
return $items; | |
} | |
add_filter( 'wp_nav_menu_items', 'ict_bz_add_logo_to_menu', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment