Adding phone number to header

So I have read a bunch of topics on adding custom files to child theme and I have done just that. I added _navbar.php and copied the code and added simple phone number div but it will not show up on the website. I don’t know whether I am meant to “connect” it in some way, as in how does it know to pull the code from there? I am a complete PHP beginner so I apologise if this is a stupid question. Thanks in advance.

Website is - http://robynreynolds.com.au/

code I have is

<?php

// =============================================================================
// VIEWS/GLOBAL/_NAVBAR.PHP
// -----------------------------------------------------------------------------
// Outputs the navbar.
// =============================================================================

$navbar_position = x_get_navbar_positioning();
$logo_nav_layout = x_get_logo_navigation_layout();
$is_one_page_nav = x_is_one_page_navigation();

?>

<?php if ( ( $navbar_position == 'static-top' || $navbar_position == 'fixed-top' || $is_one_page_nav ) && $logo_nav_layout == 'stacked' ) : ?>

  <div class="x-logobar">
    <div class="x-logobar-inner">
      <div class="x-container max width">
        <?php x_get_view( 'global', '_brand' ); ?>
      </div>
    </div>
<div class="phone-number">0402 334 465</div>
  </div>

  <div class="x-navbar-wrap">
    <div class="<?php x_navbar_class(); ?>">
      <div class="x-navbar-inner">
        <div class="x-container max width">
          <?php x_get_view( 'global', '_nav', 'primary' ); ?>
        </div>
      </div>
    </div>
  </div>

<?php else : ?>

  <div class="x-navbar-wrap">
    <div class="<?php x_navbar_class(); ?>">
      <div class="x-navbar-inner">
        <div class="x-container max width">
          <?php x_get_view( 'global', '_brand' ); ?>
          <?php x_get_view( 'global', '_nav', 'primary' ); ?>
        </div>
      </div>
    </div>
  </div>

<?php endif; ?>

I added the same div to the x theme parent folder and it worked. But if I update X theme if i’m not mistaken, it will delete the div.

Hi @aiad_development,

Thanks for writing in.

Yes, your code will be overwritten after updating. You could have setup your child theme properly so that your codes will not be overwritten. Follow this thread below on how to setup your child theme:

For child theme guide or customization guide:

Let us know how it goes.

Thanks.

Hi there,
I have a child theme and it is already activated. It still did not execute the code. It only executed it when put in the parent X php file. Any suggestions?

update-

I copied the _navbar.php file from the following file path

public_html/wp-content/themes/x/framework/legacy/cranium/headers/views/global

does that mean in order for it to work in my child theme I need to put it in

public_html/wp-content/themes/CHILD-THEME/framework/legacy/cranium/headers/views/global

Hi,

Yes, that’s correct. You need to put it on the same path as it is in your parent theme.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.