• Hi friends, I have a problem with my theme customizer not updating accordingly to my code.
    For example, I have this code:
    <?php // Display the Custom Logo
    the_custom_logo();
    // No Custom Logo, just display the site’s name
    if (!has_custom_logo()) {
    ?>
    “><?php bloginfo(‘name’); ?>
    <?php
    }
    ?>

    Which allows the user to either upload a logo, or have the default theme name shown instead.
    When user uploads a logo, it removes the text, when the user choose text, it removes the logo and that works correctly
    But inside customizer, when you add a logo, it’s simply shown beside the text – and when you remove the logo, both the logo and the logo text is removed, leaving it completely blank.
    It correctly if you refresh the page after each change, but that’s kinda messy

    Does anyone have any experience with this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Can you re-post your code using the code button so we can see what code you’re using to implement the logo/sitename?

    Thanks.

    Thread Starter Lighthouse

    (@lighthouseseo)

    Ah yes sorry @themesumo here we go:

    <?php // Display the Custom Logo
    the_custom_logo();
    // No Custom Logo, just display the site’s name
    if (!has_custom_logo()) {
    ?>
    “><?php bloginfo(‘name’); ?> 
    <?php
    }
    ?>

    From what I can see, adding text shouldn’t be removing the logo, the logo function isn’t within your if statement.

    You also have “> within your code when it shouldn’t be.

    Try this instead:

    <?php 
    if (!has_custom_logo()) { 
    bloginfo('name'); 
    } else {
    the_custom_logo();
    } ?>

    Try to paste the contents of the_custom_logo function here too.

    Thread Starter Lighthouse

    (@lighthouseseo)

    Thank you so much for helping, well it works perfectly on the website itself, when you refresh.
    So the bug is only in wp customizer, when I for example click “Add logo” then add a logo, then it does indeed remove the blog name; but when I then click remove logo, then it doesnt re-add the blog name for some reason (it does on the website, but not in customizer) making the user think that the blog name isn’t re-added :S

    The the_custom_logo is a WP function, not one I wrote myself

    • This reply was modified 8 years, 4 months ago by Lighthouse. Reason: forgot the last part

    I’m not too sure why that could be happening, it would involve inspecting the theme code itself and testing on my own WP environments to see if I could replicate the issue.

    Which theme are you using?

    Thread Starter Lighthouse

    (@lighthouseseo)

    @themesumo it is very kind of you to help! I’m using Nisarg where I have implemented it, so the nav looks like this:

    <nav class=”navbar lh-nav-bg-transform navbar-default navbar-fixed-top navbar-left” role=”navigation”>
    <!– Brand and toggle get grouped for better mobile display –>
    <div class=”container” id=”navigation_menu”>
    <div class=”navbar-header”>
    <?php if ( has_nav_menu( ‘primary’ ) ) { ?>
    <button type=”button” class=”navbar-toggle” data-toggle=”collapse” data-target=”.navbar-ex1-collapse”>
    <span class=”sr-only”>Toggle navigation</span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    </button>
    <?php
    if (!has_custom_logo()) {
    bloginfo(‘name’);
    } else {
    the_custom_logo();
    } ?>

    </div>
    <?php if ( has_nav_menu( ‘primary’ ) ) {
    lighthouse_header_menu(); // main navigation
    }
    ?>

    </div><!–#container–>
    </nav>

    It’s very odd! The rest seems to update fine, it’s just the logo/blog name that bugs out like that ??
    And it’s weird, in the customizer if i refresh the page it displays it correctly, it’s just like its not able to update it right for some reason

    • This reply was modified 8 years, 4 months ago by Lighthouse.
    • This reply was modified 8 years, 4 months ago by Lighthouse.
    • This reply was modified 8 years, 4 months ago by Lighthouse.
    Thread Starter Lighthouse

    (@lighthouseseo)

    It wont allow me to post it in the code tag for some reason

    <nav class=”navbar lh-nav-bg-transform navbar-default navbar-fixed-top navbar-left” role=”navigation”>
    <div class=”container” id=”navigation_menu”>
    <div class=”navbar-header”>
    <?php if ( has_nav_menu( ‘primary’ ) ) { ?>
    <button type=”button” class=”navbar-toggle” data-toggle=”collapse” data-target=”.navbar-ex1-collapse”>
    <span class=”sr-only”>Toggle navigation</span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    </button>
    <?php
    if (!has_custom_logo()) {
    bloginfo(‘name’);
    } else {
    the_custom_logo();
    } ?>
    
    </div>
    <?php if ( has_nav_menu( ‘primary’ ) ) {
    lighthouse_header_menu(); 
    }
    ?>
    
    </div>
    </nav>

    This Nisarg theme?

    I’ve installed it on my test site and I can’t find any Logo option, only a header image and site title options within the customizer, which work fine.

    If the theme is a commercial theme then I would suggest you try to get in touch with their support team as we’re not supplied commercial products to be able to assist you.

    Forum Welcome: Commercial Products

    If it’s some other theme then please point me in the right direction so I can try to inspect further.

    Thanks.

    Thread Starter Lighthouse

    (@lighthouseseo)

    I really appreciate you helping me!
    It’s not a paid version of their theme, it’s in their theme where I added this

    <?php 
    if (!has_custom_logo()) { 
    bloginfo('name'); 
    } else {
    the_custom_logo();
    } ?>

    So the header.php code navigation looks like this:

    <nav class=”navbar lh-nav-bg-transform navbar-default navbar-fixed-top navbar-left” role=”navigation”>
    <div class=”container” id=”navigation_menu”>
    <div class=”navbar-header”>
    <?php if ( has_nav_menu( ‘primary’ ) ) { ?>
    <button type=”button” class=”navbar-toggle” data-toggle=”collapse” data-target=”.navbar-ex1-collapse”>
    <span class=”sr-only”>Toggle navigation</span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    <span class=”icon-bar”></span>
    </button>
    <?php
    if (!has_custom_logo()) {
    bloginfo(‘name’);
    } else {
    the_custom_logo();
    } ?>
    
    </div>
    <?php if ( has_nav_menu( ‘primary’ ) ) {
    lighthouse_header_menu(); 
    }
    ?>
    
    </div>
    </nav>
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Customizer not updating correctly’ is closed to new replies.