Skip to content

Instantly share code, notes, and snippets.

@norewp
Last active December 6, 2017 17:11
Show Gist options
  • Save norewp/7601a4781f41be7fc98c1b62a0354825 to your computer and use it in GitHub Desktop.
Save norewp/7601a4781f41be7fc98c1b62a0354825 to your computer and use it in GitHub Desktop.
<?php
function nore_home_logo() {
$centered_logo = '';
$handle = 'nore-style';
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo_render = wp_get_attachment_image_src( $custom_logo_id , 'full' );
$centered_logo .= 'header .main-navigation ul > li.my-site-logo a {background-image: url(' . esc_url( $logo_render[0] ) . ');}';
wp_add_inline_style( $handle, $centered_logo );
}
add_action( 'wp_enqueue_scripts', 'nore_home_logo', 200 );
@norewp
Copy link
Author

norewp commented Dec 5, 2017

Your CSS would be something like this - adjust for your needs but leave this text-indent: -9999em; as is (important)

.main-navigation ul > .my-site-logo a {
        background-position: center center;
        background-repeat: no-repeat;
        text-indent: -9999em;
        width: 150px;
	height: 150px
 }

Note: This is a theme specific but the idea is the same for all menus. For Elementor you'll need to inspect your custom header to get the right CSS elements to target!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment