0

I hope anyone can help me.

Is there a way to toggle the visibility of a Divi module with ACF in Wordpress?

I tried it myself an searched in forums

1 Answer 1

1

Yes, you can use ACF Plugin for that.

Steps for that:

  1. Install the ACF plugin.
  2. create the new custom field group in ACF and add the toggle field in that.
  3. Assign this group to relevant post types and taxonomy.
  4. Edit the Divi module that you watch to show/hide based on the ACF field.
  5. Go to the advanced tab in the module setting and add the CSS class "acf-toggle-module".
  6. Add the below code to your theme function file(Function.php).

add_filter( 'body_class', 'acf_toggle_module_class' );
function acf_toggle_module_class( $classes ) {
    if( get_field('acf_toggle_module') ) {
        $classes[] = 'hide-module';
    }
    return $classes;
}

  1. Add the CSS to style sheet(Style.css).

.hide-module .acf-toggle-module {
    display: none !important;
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.