Divi  – A section above the main header

Divi – A section above the main header

This is a cool way to add a whole section (or layout if you wish) above the main navigation and then have it stick to the top during scroll. It’s pretty cool.

Preview

This is what it looks like:

https://imgur.com/a/tbNNbvR

 

You need this

To start with, go get the child theme,

or if you’re using a child theme, add this code to your functions.php

And make sure your header is set to stick to the top.

 

The video

 

The code

Here’s the php code you need to add right above header id=”main-header” in the header.php file. (copy the header.php from Divi into the child theme if it’s not already there. Edits to the child theme file won’t be lost on updates to the parent theme)

<?php if ( is_home() || is_front_page() ) : 
	echo do_shortcode('[ai_layout_sc id="000000"]');
 endif; ?>

Please change the shortcode id number to whatever number your section had in the library.

Then add this CSS

.home.page #page-container {
 padding-top:0px !important
}
.home.page #page-container header#main-header {
 position:relative;
 -webkit-transition:all 0.5s ease-in-out;
 -moz-transition:all 0.5s ease-in-out;
 -o-transition:all 0.5s ease-in-out;
 -ms-transition:all 0.5s ease-in-out;
 transition:all 0.5s ease-in-out
}
.home.page #page-container header#main-header.et-fixed-header {
 position:fixed;
 -webkit-transition:all 0.5s ease-in-out;
 -moz-transition:all 0.5s ease-in-out;
 -o-transition:all 0.5s ease-in-out;
 -ms-transition:all 0.5s ease-in-out;
 transition:all 0.5s ease-in-out
}

[sc name=”customcss”]

 

and you’re done!

 

[sc name=”learn css”]

 

 

Photo by Li Yang on Unsplash

Get Breakdance

Breakdance is, in my opinion, the best page/site builder on the market, which is why all my tutorials use Breakdance. It's also why I have an affiliate link. You don't pay extra, but I get a little commission, so it helps support the site. Thanks!

Get ACF Pro

Another essential plugin for site building. This isn't an affiliate link, it's just for convenience.

Get WP Codebox Pro

If you'd like an easier to use, and more advanced code management plugin (instead of just editing and making files yourself) then WP codebox pro is for you. Adding php, js, and even SCSS. Pretty nice! Affiliate link below.

Blank Plugin

Sort of blank. It's made to be easy to use with the tutorials. Download and edit any way you see fit.
  1. Nice work! Could you use cooie or session or something to display this only when user first time visit homepage?

    • Hi, unfortunately, I’m not good with setting cookies, sorry. You might have to use popups for this.

Leave a Reply

Your email address will not be published. Required fields are marked *

New tutorials

Auto-updating Year in Footer
Designing Beyond the Brief
Disable Gutenberg Editor on some ACF pages
ACF flexible content fields in Breakdance 2.4

Got a question? ask!

If you have any question about the content on this page, feel free to send me an email by clicking the button below.

newsletter? sign up!

Sign up to the newsletter for updates on tutorials, news, and offers.

Join the cypher!

An awesome membership program for Breakdance Builder users coupled with an inclusive, friendly community.

Got a question?

If you have a question about something on this page, send me an email, and hopefully I can answer, and we can solve it!