'wordpress "the_custom_logo" not fetching my image in the library
I am trying to create my owm custom theme in wordpress, i want to pull the selected logo which is already in my library, i have trouble getting the "the_custom_logo" method to work.
Upon checking this method turns out that, when it calls the "get_theme_mod('custom_logo')", it doesnt return any id. Below is my code.
//functions.php
function custom_wordpress_theme_themesupport(){
//Adds dynamic title tag support
add_theme_support('title-tag');
add_theme_support('custom-logo',array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
'unlink-homepage-logo' => true,
));
}
add_action('after_setup_theme','custom_wordpress_theme_themesupport');
//header.php
<header class="header text-center">
<a class="site-title pt-lg-4 mb-0" href="index.html">SiteName.dev</a>
<nav class="navbar navbar-expand-lg navbar-dark" >
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navigation" class="collapse navbar-collapse flex-column" >
<?php
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
?>
.....
Solution 1:[1]
Your code looks fine. It might sound silly, but are you selecting your image from the "Site Identity" section?
Solution 2:[2]
I made this mistake where I uploaded the logo under the 'site icon' and not the 'logo' section under Appearance > Customize > Site Identity.
The code should work fine once you uploaded your logo there.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Daniel Akio Oizumi |
Solution 2 | Xiwen Yeoh |