Skip to content

Instantly share code, notes, and snippets.

@geeac
Created March 20, 2017 10:04
Show Gist options
  • Save geeac/df08c8fdc30cf20ba1c2e0d1b2301e17 to your computer and use it in GitHub Desktop.
Save geeac/df08c8fdc30cf20ba1c2e0d1b2301e17 to your computer and use it in GitHub Desktop.
Move logo in center of the main menu
// https://sridharkatakam.com/split-navigation-menu-items-logos-left-right-genesis/
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 200,
'height' => 200,
'header-selector' => '.site-title a',
'header-text' => false,
'flex-height' => true,
) );
// if header image is set, remove Header Right widget area and inject CSS to apply the header image as background image for home menu item and more
add_action( 'wp_head', 'sk_home_menu_item_background_image' );
function sk_home_menu_item_background_image() {
if ( get_header_image() ) {
// Remove the header right widget area
unregister_sidebar( 'header-right' ); ?>
<style type="text/css">
.nav-primary li.menu-item-home a {
background-image: url(<?php echo get_header_image(); ?>);
text-indent: -9999em;
width: 100px;
height: 100px;
}
@media only screen and (min-width: 1024px) {
.site-header > .wrap {
padding: 0;
}
.title-area {
display: none;
}
.nav-primary {
padding: 20px 0;
}
.menu-primary {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center; /* center flex items horizontally */
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center; /* center flex items vertically */
}
}
</style>
<?php }
}
<style>
.header-image .site-title > a {
min-height: 100px;
}
@media only screen and (min-width: 1024px) {
.nav-primary li.menu-item-home a {
background-repeat: no-repeat;
background-size: contain;
margin: 0 10px;
}
}
@media only screen and (max-width: 1023px) {
.js .nav-primary .genesis-nav-menu .menu-item.menu-item-home {
display: none;
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment