Last active
April 11, 2016 21:27
-
-
Save WPDevHQ/8f0aa6518bcc3cf1a2e7 to your computer and use it in GitHub Desktop.
How to add Site Logo support to a 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 | |
/* | |
* First we need to let WordPress know that our theme supports the output of the "custom-logo" | |
* We do this by making the "add_theme_support( 'custom-logo' ) plus arrays declaration as follow. | |
* File: functions.php | |
*/ | |
function themename_setup() { | |
add_theme_support( 'custom-logo', array( | |
'height' => 250, | |
'width' => 75, | |
'flex-height' => true, | |
) ); | |
} | |
add_action( 'after_setup_theme', 'themename_setup' ); | |
/* | |
* We then need to create a function that will return our uploaded logo in the header template or whereever we choose to add the logo. | |
* File: functions.php | |
*/ | |
if ( ! function_exists( 'themename_the_custom_logo' ) ) { | |
/** | |
* Displays the optional site logo. | |
* | |
* Returns early if the site logo is not available. | |
* | |
* @since ThemeName 1.0.0 | |
*/ | |
function themename_the_custom_logo() { | |
if ( function_exists( 'the_custom_logo' ) ) { | |
the_custom_logo(); | |
} | |
} // We can now call this function in place where we want the logo to appear | |
} | |
/* | |
* Note that you will need to add some CSS to adjust the logo position that best suites your theme. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment