Skip to content

Instantly share code, notes, and snippets.

@neverything
Created June 17, 2015 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neverything/c30924b53c926b3ab45b to your computer and use it in GitHub Desktop.
Save neverything/c30924b53c926b3ab45b to your computer and use it in GitHub Desktop.
This function adds a logo as a first menu item.
<?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