ign_logo()
This returns a string of html that has your logo in an anchor tag that links to the front page of your site. It will return inside an h1 header tag on the front page, while on all other pages it will return in a p tag.
File: inc/extras.php
function ign_logo() {
if ( has_custom_logo() ) {
$logo = get_custom_logo();
} else { //no theme mod found. Get site title instead.
$logo = '<a href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . get_bloginfo( 'name' ) . '
</a>';
}//theme mod
//if we are in the customizer preview get both image and site title and hide/show based on js
if ( is_customize_preview() ) {
return '<div class="site-logo"><h1 class="site-title">' . $logo . '<a class="site-name" href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . get_bloginfo( 'name' ) . '
</a>' . '</h1></div>';
}
if ( is_front_page() ) {
//$logo is the custom logo wrapped in a link
return '<div class="site-logo"><h1 class="site-title">' . $logo . '</h1></div>';
} else {
return '<div class="site-logo"><p class="site-title">' . $logo . '</p></div>';
}
}
Usage
echo ign_logo();