Last active
October 20, 2019 10:55
-
-
Save vanaf1979/44336efe0a2cfccc924474c4feb4fa3b to your computer and use it in GitHub Desktop.
Gist for my article: WordPress: Add custom logo support to your theme. https://vanaf1979.nl/wordpress-add-custom-logo-support-to-your-theme/
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 theme_get_custom_logo() { | |
if ( has_custom_logo() ) { | |
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ) , 'full' ); | |
echo '<a class="custom-logo-link" href="' . get_site_url() . '" >'; | |
echo '<img class="custom-logo" src="' . esc_url( $logo[0] ) . '" width="' . $logo[1] . '" height="' . $logo[2] . '" alt="' . get_bloginfo( 'name' ) . '">'; | |
echo "</a>"; | |
} else { | |
echo '<h1>'; | |
echo '<a href="' . get_site_url() . '">' . get_bloginfo( 'name' ) . '</a>'; | |
echo '</h1>'; | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment