Custom Logo is a powerful Feature added in WordPress 4.5. Using this features helps you to easily change logo by simple uploading a logo image. if you are using theme option or WP customizer previously for custom logo then it saves your time..
To use custom logo feature in your Theme, you first need to conform that you are updated to WordPress 4.5.
Here are the steps to Implement custom logo
custom logo is wordpress core feature, you need to define support for custom logo. To define support for custom logo. Paste below code to your function.php
To use custom logo feature in your Theme, you first need to conform that you are updated to WordPress 4.5.
Here are the steps to Implement custom logo
custom logo is wordpress core feature, you need to define support for custom logo. To define support for custom logo. Paste below code to your function.php
Enable support for custom logo in function.php
// Enable support for custom logo.
add_theme_support( 'custom-logo');
you can also define image size and other parameter like width, height
// Enable support for custom logo.
add_theme_support( 'custom-logo', array(
'height' => 80,
'width' => 360,
'flex-width' => true, (Whether to allow for a flexible width.)
'flex-height' => true, (Whether to allow for a flexible height.)
) );
Now you can see custom logo in customizer's Site Identity section
To Retrieve Logo in your themes front end, you can use three themplate
for Example I've created a function to retrieve logo and call function in header.php
add_theme_support( 'custom-logo');
you can also define image size and other parameter like width, height
// Enable support for custom logo.
add_theme_support( 'custom-logo', array(
'height' => 80,
'width' => 360,
'flex-width' => true, (Whether to allow for a flexible width.)
'flex-height' => true, (Whether to allow for a flexible height.)
) );
Now you can see custom logo in customizer's Site Identity section
To Retrieve Logo in your themes front end, you can use three themplate
get_custom_logo( $blog_id = 0 )
Returns markup for a custom logo.
Returns markup for a custom logo.
the_custom_logo( $blog_id = 0 )
Displays markup for a custom logo.
Displays markup for a custom logo.
has_custom_logo( $blog_id = 0 )
Returns a boolean true/false, whether a custom logo is set or not.for Example I've created a function to retrieve logo and call function in header.php
// retrive logo from customizer
function griffion_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
function griffion_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
call function to display logo
<?php griffion_custom_logo(); ?>
<?php griffion_custom_logo(); ?>