Nothing happens when I edit header.php

Hello and regards to you at wpmudev, If it is not too much to ask, I am trying to add user avatar to header. But when I try to paste in the code, nothing happens, same thing when I try to add a search form.. What could be the problem?
I have enabled access incase you want to have a close look. Thanks

  • Predrag Dubajic

    Hey Schmirts,

    Even though I can access your theme files from WP admin section it's not safe way to make changes to files as it can format the code incorrectly and mess up your site so I didn't want to make any changes in there.

    Could you add your desired code inside header.php, let me know what code you added and I'll have a look at the file and check if I can see why it's not being loaded?

    Best regards,

  • Adam Czajczyk

    Hello Schmirts!

    I checked your site and "header.php" code and it seems that your theme includes integration with Beaver Builder plugin.

    The section of the header code where you put your avatar fetching snipped is called out only if the Beaver Builder plugin is active. Since this plugin is not active (and not even installed) on your site, this part of the header is not used so your code is not used either.

    Try moving your code from its current location down please, preferably locate it inside this section of code:

    <?php } else { ?>
    <header id="masthead_TesseractTheme" class="site-header <?php echo $rightclass . $headpos . ' ' . 'menusize-' . $hmenusize_class . ' '; echo get_header_image() ? 'is-header-image' : 'no-header-image'; ?>" role="banner">
      <div id="site-banner" class="cf<?php echo ' ' . $headright_content . ' ' . $brand_content; ?>">
        <div id="site-banner-main" class="<?php echo ( ( $headright_content  ) && ( $headright_content !== 'nothing' ) ) ?  'is-right' : 'no-right'; ?>">
          <div id="mobile-menu-trigger-wrap" class="cf"><a class="<?php echo $rightclass; ?>menu-open dashicons dashicons-menu" href="#" id="mobile-menu-trigger"></a></div>
          <div id="site-banner-left">
            <div id="site-banner-left-inner">
              <?php if ( $logoImg || $blogname ) { ?>
              <div class="site-branding <?php if ( ! display_header_text() ) { echo 'hide-header-text'; } ?>">
                <?php if ( $logoImg ) : ?>
                <h1 class="site-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><img src="<?php echo $logoImg; ?>" alt="logo" /></a></h1>
                <?php else : ?>
                <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                  <?php bloginfo( 'name' ); ?>
                <?php endif; ?>
              <!-- .site-branding -->
              <?php } ?>
              <?php //$menuSelected = get_theme_mod('tesseract_header_menu_select');
    							//if ( $menuSelected !== 'none' ) : ?>
              <nav id="site-navigation" class="<?php echo $mmdClass; ?> main-navigation top-navigation <?php echo $hmenusize_class; ?>" role="navigation">
                <?php tesseract_output_menu( FALSE, FALSE, 'primary', 0 ); ?>
              <!-- #site-navigation -->
              <?php //endif; ?>
          <?php get_template_part( 'content', 'header-rightcontent' ); ?>

    It's the last "<header> .... </header>" block inside the "header.php" file and it should be called if the Beaver Builder is not active on the site. Give it a try please and let me know if that helped.

    Best regards,

  • Adam Czajczyk

    Hello Schmirts!

    It seems that the code is now in right place and the site breaks because of that error:

    <b>Fatal error</b>: Call to undefined function bp_loggedinuser_link() in <b>/home/....</b>

    This means that the "bp_loggedinuser_link()" function simply doesn't exist on your site (or is not available at the point where it's triggered). I tested that code on my end and its working fine for me but the "bp_loggedinuser_link()" function is actually marked as deprecated and even though it shouldn't be removed from BuddyPress yet it's worth replacing it with a current one. That said, please try replacing this part of your code

    <?php bp_loggedinuser_link() ?>

    with this one

    <?php bp_loggedin_user_link() ?>

    Let me know if that works for you, please.

    Best regards,

  • Adam Czajczyk

    Hello Schmirts!

    This was working for me when I tested it using browser's CSS editor but it seems that when added directly to the site, the code I suggested gets overwritten by the theme's CSS. That's nothing unusual though as CSS rules quite often behave in a slightly different way when applied directly via browser :slight_smile:

    I have accessed your site and modified the CSS I previously gave you a bit (in "Appearance -> Custom CSS" custom CSS box, at the bottom) so now it is:

    .header-avatar img {width:50px;height:auto;max-width:50px;}
    .header-avatar {display:block!important;margin-left:30px!important;}

    It seems that it did the trick :slight_smile:

    Best regards,