Skip to content

Instantly share code, notes, and snippets.

@sergeyterr
Last active September 14, 2016 05:12
Show Gist options
  • Save sergeyterr/11b40fa9aee5fa28cdd376c22d1efe01 to your computer and use it in GitHub Desktop.
Save sergeyterr/11b40fa9aee5fa28cdd376c22d1efe01 to your computer and use it in GitHub Desktop.
добавляем логотип в customizer WordPress
function theme_prefix_setup() {
add_theme_support( 'custom-logo' );
}
add_action( 'after_setup_theme', 'theme_prefix_setup' );
// или
function theme_prefix_setup() {
add_theme_support( 'custom-logo', array(
'height' => 175,
'width' => 400,
'flex-width' => true,
) );
}
add_action( 'after_setup_theme', 'theme_prefix_setup' );
// Варианты с хидер текстом
add_theme_support( 'custom-logo', array(
'header-text' => array( 'site-title', 'site-description' ),
) );
// Получение
// Returns markup for a custom logo.
get_custom_logo( $blog_id = 0 )
// Displays markup for a custom logo.
the_custom_logo( $blog_id = 0 )
// Returns a boolean true/false, whether a custom logo is set or not.
has_custom_logo( $blog_id = 0 )
function twentysixteen_the_custom_logo()
{
if ( function_exists( 'the_custom_logo' ) )
{
the_custom_logo();
}
}
/*
height
(int) Expected logo height in pixels.
Themes can use built-in image sizes (like thumbnail) or register a custom image size and use that.
width
(int) Expected logo width in pixels.
flex-height
(boolean) Whether to allow for a flexible height.
Showing the logo in a vertical sidebar (like Twenty Fifteen) is a good example for when a flexible height can make sense.
flex-width
(boolean) Whether to allow for a flexible width.
If a theme has room horizontally, flex-width gives users more freedom in how their logo can be displayed.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment