Add Logo Upload to Themes That Lack It
Adds the "Logo" option to the Customizer for older classic themes that do not support a custom logo, with flexible width and height.
Opens WPIDE on
Code
add_action( 'after_setup_theme', function () {
if ( current_theme_supports( 'custom-logo' ) ) {
return;
}
add_theme_support( 'custom-logo', array(
'height' => 120,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'unlink-homepage-logo' => true,
) );
}, 20 );
Notes
Your theme still needs to print the logo, for example with the_custom_logo() in header.php.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.