Last active
September 14, 2023 12:23
-
-
Save pingram3541/033eca97dd7f71e8cddb8f7fda393d50 to your computer and use it in GitHub Desktop.
How to hide Elementor Section or Widget for use with custom conditional
This file contains hidden or 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
//How to hide any widget with an id of 'test': | |
add_filter( 'elementor/frontend/widget/should_render', function( $bool, $element ){ | |
$settings = $element->get_settings(); | |
if( 'test' === $settings['_element_id'] && 'heading' === $type ){ | |
return false; | |
} else { return true } | |
}, 10, 3); | |
//How to hide any specific type of widget': | |
add_filter( 'elementor/frontend/widget/should_render', function( $bool, $element ){ | |
$type = $element->get_name(); | |
if( 'heading' === $type ){ | |
return false; | |
} else { return true } | |
}, 10, 3); | |
//How to hide any section with an id of 'test' | |
add_filter( 'elementor/frontend/section/should_render', function( $bool, $element ){ | |
$settings = $element->get_settings(); | |
if( 'test' === $settings['_element_id'] ){ | |
return false; | |
} else { return true } | |
}, 11, 3); //needs priority > 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you