Now that we have gone through the problem step by step, we know the code in customizer.php
is working because :
get_theme_mods
returns your logo file so the problem’s not the database or theme mods.var_dump
shows that the logo file is saved in thesticky_header_logo
array key as expected.
The problem:
This means that the problem must be in header.php
so we have narrowed down where to start looking for the coding problem. The marvels of debugging 🙂 If we look at the code you are using to show the second logo:
<div class="site-branding-alternative"> <?php get_theme_mod( 'sticky_header_logo' ) ?> </div>
You are using the get_theme_mod
to get the value of sticky_header_logo
which is correct… but you are not displaying the result. This function doesn’t output the logo in the same way that the_custom_logo
does, it just returns the url.
To fix the problem:
You need to create the <img>
tag using the url returned from get_theme_mod
and echo it to the screen, e.g.:
<div class="site-branding-alternative"> <?php $sticky_logo_url = get_theme_mod( 'sticky_header_logo' ); if ($sticky_logo_url ) echo '<img src="'.$sticky_logo_url.'" alt = "logo alt test" class="sticky_logo_class">'; ?> </div>
Reference: