Show / Hide Content with a Button in the Divi Menu

|

If you'd like to be able to include a button in a Divi menu which, when clicked, displays (or hides) content in the site, here's how to do it.

Add a Divi Show / Hide Button to the Default Divi Menu

The Divi Show / Hide Button module lets you add a Divi-style button to Divi builder layouts which reveal, hide and toggle content at a click of a button. While it doesn't yet have an option to add a button into the Divi default menu, you can add a show / hide button to the main Divi menu by:

1. Saving a show / hide button to the Divi Library
2. Getting the post ID of the module in the Divi Library (e.g. from the "post" value in the URL when you're on the "Edit Layout" screen).
3. Adding the following PHP code to your site, replacing "18" with the ID of your module:

add_action('et_header_top', 'dbc_add_show_hide_button_to_header');

function dbc_add_show_hide_button_to_header() {
	echo do_shortcode('[et_pb_db_show_hide_button global_module="18"][/et_pb_db_show_hide_button]');
}

4. You should then see the button in the main menu similar to this:

Add a Divi Show / Hide Button to a Theme Builder Header

For the menu module / theme builder header, the easiest way to do it, if your layout allows, is to simply add a Divi Show / Hide Button module into the theme builder header layout.

Then, if you need to you can move it into position next to your menu using the options at "Show / Hide Button module > Advanced > Position". In particular, if you set its "Position" as "absolute", you can then use the horizontal / vertical offsets to place it anywhere in the header.

You may also need to set the z-index to ensure it appears in front of other elements.

So the settings would end up looking like this:

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

Your email address will not be published.