Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from pingram3541/functions.php
Created July 25, 2025 10:20
Show Gist options
  • Select an option

  • Save dexit/f9d29d6f5fb458d150de444b08914a84 to your computer and use it in GitHub Desktop.

Select an option

Save dexit/f9d29d6f5fb458d150de444b08914a84 to your computer and use it in GitHub Desktop.
How to hide Elementor Section or Widget for use with custom conditional
//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