X_masthead location in PHP

I want to modify the header to display 2 headers at the same time. I found masthead.php which calls do_action(‘x_masthead’) but I can’t find the PHP file where PRO decides which header to show. Where is this file? I’d like to modify that file so that it pulls 2 headers.

Thanks.

Hi There,

Can you clarify what you are trying to achieve? On Pro you are able to assign different headers to different pages. Beside that if you want to emulate having two headers you could do that using th header builder. So please provide a more detailed information and if possible a mockup of what you are trying to achieve.

Thank you

Hi @Joao,

I want to have 2 top headers on the same page. Here’s what I want to achieve:

PAGE 1

  • Company header: Logo - address - phone number
  • Product A header: Product A - About A - Reviews about A - etc.

PAGE 2

  • Company header: Logo - address - phone number
  • Product B header: Product B - About B - Reviews about B - etc.

Now I understand that I can build that out using the header builder: Page 1 Header and Page 2 Header. The problem with that is if I need to change the Company header, I would have to do it on EVERY header page. For example, if I add a “tagline” to Company header, I would need to go into every single header and manually add that.

So I was looking for a way to assign 2 different headers to the same page:

  • Company header -> assigned to every page
  • Product A header -> assigned to Product A pages.

Currently, if I do that, Product A header would replace Company header.

The result I want: On product A’s page:

  • Company header bar
  • Product A header

This way, I can just modify Company header bar once and be done!

Hi there,

Thanks for writing in.

Instead of modifying the templates and codes directly, you could use a shortcode within the header. Example, let’s say you have this code in your child theme’s functions.php

add_shortcode('company_header_element', 'company_header_element');

function company_header_element ( $atts ) {

switch ( $company ) {
case "HP" : return "HP Company"; break;
case "Apple" : return "HP Company"; break;
}

}

add_shortcode('product_header_element', 'product_header_element');

function product_header_element ( $atts ) {

switch ( $company ) {
case "iphone" : return "iPhone"; break;
case "note 2" : return "Note 2"; break;
}

}

Then you can simply assign one single header with 2 bars, and each bar has text element where the shortcodes will be added.

[company_header_element]
[product_header_element]

If you’re creating a complete set of header instead of just displaying text, then you may try it like this

case "HP" : ob_start(); ?>

<h1>HP Copmany</h1>
<img src="company_logo.jpg">

<?php return ob_get_clean(); break;

You can follow the structure you like while still using the Pro header as the wrapper, the good thing is you can assign them. The output depends on your coding, the alignment of logo, address, and phone number is up to you :slight_smile:

Thanks!

@Rad thanks for the reply.

I like your solution, but the problem is when I want to make it responsive.

Inside [company_header_element], I want to include a responsive menu. When it is on the computer, it shows the entire menu. When it is on a smartphone, the menu becomes a button. I don’t know how to do that using:

case "HP" : ob_start(); ?>
<h1>HP Copmany</h1>
<img src="company_logo.jpg">
<?php return ob_get_clean(); break;

That’s why I was hoping to be able to reference another header that was built using Pro header.

Hi There,

On this file: wp-content\themes\pro\framework\legacy\cranium\headers\views\global\_nav-primary.php, you can see the structure of legacy header navigation. You can use that guide on how switch happens on mobile and desktop menu. The function you are looking for is part of the header builder and it is not recommended to change/update.

We have shown you possible solution and where you can start but if you are not sure how to proceed from there we do recommend to consult a web developer. We do have an in-house custom development team that offer paid services, who may be able to assist. They can be contacted at pinnacle@theme.co if this is of interest to you. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

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