Creating Top Bar before Header

Hello all,

I am new to BRICKS and not a developer, so I am missing some skills.

I have created a header and turned on the sticky function when scrolling. However, I also have a top bar that should not run when I am scrolling.

is there a way that the top bar is excluded from this function or a hook to set a template before the header?

thank you guys :slight_smile:

1 Like

Hi @vectswipe.

Welcome to the forum!

There’s indeed bricks_before_header hook that can be used for this.

// Render a Bricks Template by its ID above the site header.
add_action( 'bricks_before_header', function() {
	echo do_shortcode( '[bricks_template id="1229"]' );
});

Replace 1229 with the ID of your top bar template.

You may have to add this CSS at Bricks → Settings → Custom code → Custom CSS:

#brx-header.sticky {
	position: sticky;
}
2 Likes

Hey Sridhar,

thank you for your help :sunny:
I think I have to insert the add_action into CodeSnippets or is there another way in Bricks to do that?

Yes - Child theme’s functions.php.

Hi,
Where is this hook in the documentation ?
Thanks.

1 Like

Can you link the DOCS for this?

// Render a Bricks Template by its ID above the site header.
add_action( ‘bricks_before_header’, function() {
echo do_shortcode( ‘[bricks_template id=“1229”]’ );
});