Divi Tutorials + Layout Kits | WordPress Tips | Business Growth

Home of the Original Divi Tutorials & Divi Layout Kits.

Divi Tutorials + Layout Kits | WordPress Tips | Business Growth

Home of the Original Divi Tutorials & Divi Layout Kits.

Have you ever wanted to replace the Divi Top Header with Divi Page Builder Layout from the Divi Library? Now you can inject a custom Divi layout from your Divi Library above your Default Divi Main Header using the new Divi Hooks. All we have to do is add a simple snippet of PHP to your functions.php file.

This is great if you want to add more content, call to actions, advertisements, and more, above your default main header just like on the Elegant Themes website.

So in this tutorial, I will show you how to inject a custom Divi library layout above your Default Divi Main Header. To do this you will need a basic child theme with a functions.php file.

UPDATE: If you are using a child theme that with an older version of Divi’s header.php and footer.php, before they added the hooks, then you will need to update those files.

Let’s Get Started Setting up the Divi Header Section.

 

Disable the Divi Top Header

1. Since we are replacing the top header with a Divi Layout, you want to make sure you are not currently using the Divi default top header. Go to the Customizer>>Header & Navigation>Header Elements and make sure the boxes are not ticked and there is no phone number or email.

 

Fixed Navigation

2. If you’re using a fixed navigation bar, the injected layout is displayed below the main menu, and it scrolls with the rest of the page. In order for this to work like the demo, you will need to disable the fixed navigation. Go to Divi Theme Options and disable the fixed navigation.

3. If you prefer to keep the Fixed Header enabled, you can assign a custom ID to the layout. See #7 below.

 

Adding the layout

4. Go to your Divi Library and add a new layout.

 

5. Give it a name and choose Layout as the the Layout Type.

 

6. In my demo I am creating a section for a social media module, and tagline, and a button module.

 

7. If you plan on enabling the Fixed Header, you will have to assign the following ID to the Layout section otherwise the section will show beneath the fixed header/menu. Use this ID: top-header

*Note: Divi applies any default Theme Customizer settings that may have been set in the Customizer. If your Divi Builder font styles are being overwritten, you might have to check the Customizer or apply some custom CSS.

Adding The PHP

8. Go to Appearance>Editor and open your functions.php file and you are going to insert the function below. Unfortunately my Syntax plugin does not know how to read the shortcode without messing up this page so you will have to write the code yourself or grab the snippet from the txt file below.

Grab The PHP Snippet

 

9. Your functions.php page should look like this after you have copied and pasted the snippet above.

 

Inserting the Divi Library Section into the PHP snippet

Now we are going to grab the layout shortcode and insert it into the PHP snippet above.

10. Go to your Divi Library and open up the layout you just created. Once you have the layout open, check out the URL and you will see a sequence of characters and numbers. You are going to want to grab the numbers as we will need that for the next steps. For example in my case, the number sequence that I want to grab is 27434. This is the URL in my example: https://montereydev.com/demos/divi/add-divi-library-layout-above-header/wp-admin/post.php?post=27434&action=edit

 

11. Go back to Appearance> Editor and open the functions.php where you added the snippet above and in this shortcode, replace the number with your own.

 

Adding The Custom CSS

For this tutorial, I am not using any custom CSS. But in the snippet above, I am adding a custom ID you can use to target the whole layout. The ID I am creating for it in the PHP is #custom-header-above

And that’s it.

If you used this on one of your projects, please share a link below so we can see how you used it.

Have fun!


Well, that’s all for now. I hope you find this article useful.


The following two tabs change content below.
Geno is an entrepreneur who has been designing websites since 1996. He also enjoys all things design, traveling, hanging out with friends, encouraging other believers, and experimenting with new technologies. When not doing any of the above, you can find Geno blogging or writing Divi customization tutorials here on Quiroz.co.

©2012-2019 Geno Quiroz | Teach Learn Build Love | Divi Expert ServicesJohn 3:16

Divi is a registered trademark of Elegant Themes, Inc. This website is not affiliated with nor endorsed by Elegant Themes.

STAY RELEVANT | BE INFORMED | SIGN UP NOW

IT DOES NOT TAKE LONG TO GET LEFT BEHIND!

You have Successfully Subscribed!

Pin It on Pinterest