Skip to content

Instantly share code, notes, and snippets.

@pingram3541
Last active September 14, 2023 12:23
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingram3541/033eca97dd7f71e8cddb8f7fda393d50 to your computer and use it in GitHub Desktop.
Save pingram3541/033eca97dd7f71e8cddb8f7fda393d50 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
@alexandru-burca
Copy link

thank you

@pixelbart
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment