Created
August 10, 2018 18:34
-
-
Save JeffAspen/b33398541bdc44783ed5008b28642429 to your computer and use it in GitHub Desktop.
Elementor - Hide widgets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Hide Elementor sections / elements when acf field is empty. Everything is shown when editor is active | |
// Usage: Add acf__[field_slug] classname into the desired element (for example acf__caption, acf__map-section) | |
$all_acf_fields = get_fields(); | |
echo '<style>'; | |
foreach($all_acf_fields as $acf_field_slug => $acf_field_value) { | |
if ($acf_field_value == ''){ | |
echo 'body:not(.elementor-editor-active) .acf__'.$acf_field_slug.' { display: none; }'; | |
} | |
}; | |
unset($value); | |
echo '</style>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment