You can overwrite the display rules for a Hook using the generate_hook_element_display
filter. There also ones for _layout
, _header
and _block
https://docs.generatepress.com/article/generate_hook_element_display/
Heres an example to display a hook if the meta field is NOT empty:
add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
// Get the Meta value for condition
$conditionalMeta = get_post_meta( get_the_ID(), 'my_conditional_meta_key', true );
// If not empty display then display Element id 10
if ( 10 === $element_id && !empty($conditionalMeta) ) {
$display = true;
}
return $display;
}, 10, 2 );