Having a logo is a way to show the unique identity of a business or individual that will make it easier to remember by audiences. It also shortens the textual brand name into some pixels of a graphic. So it will reduce space in a specific area of a website, for example, header.
If you get difficulties in uploading a logo to your WordPress website, let’s find the cause and how to fix it.
- Check the theme’s customizer
Modern themes have the option to upload the logo from the customizer. However, some free ones sometimes don’t enable it by default. You can contact the theme’s author for this reason.
In case you already have an image logo uploader in your site’s customizer, but fail to upload, there may be file permission on the wp-content folder that doesn’t allow you to write the folder. You can access your site’s root folder via File Manager in your hosting and set 755 for the wp-content folder’s permission.
CSS
You can use CSS code to override the site name with an image background. For example:
.site-title a {
background-image: url('https://yoursite.com/path-to-image.png');
background-size: 100px 70px;
background-repeat: no-repeat;
}
Find the CSS class/selector of your site name link with the web browser’s inspector tool and replace .site-title a.
PHP
Other solution is by using PHP code. Add this snippet to your child theme’s functions:
function childthemename_custom_logo_setup() {
$defaults = array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
);
add_theme_support( 'custom-logo', $defaults );
}
add_action( 'after_setup_theme', 'childthemename_custom_logo_setup' );
To display the logo add this code to a file that handles the area you want the logo to show. The header area usually uses header.php.
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
That’s it! Let me know in the comment if you have easier solution.