Hi Lox,
Yes, it’s possible.
A specific filter for Hook Elements you may use is generate_hook_element_display
.
Reference: https://docs.generatepress.com/article/generate_hook_element_display/
So for instance, here’s a PHP snippet you may try:
add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
if ( 396602 === $element_id && is_page() ) {
if( ! empty ( get_ancestors ( get_the_ID(), 'page' ) ) ) {
//display if child
$display = true;
} else {
$display = false;
}
} else if ( 706 === $element_id && is_page() ) {
if( empty ( get_ancestors ( get_the_ID(), 'page' ) ) ) {
//display if parent
$display = true;
} else {
$display = false;
}
}
return $display;
}, 10, 2 );
Kindly replace 396602
with the Hook Element ID meant for the child, and 706
for the parent pages.
This only works for pages.
You would need to alter it for posts.
If you’re planning to use a Block Element instead for instance, just replace generate_hook_element_display
with generate_block_element_display
.
Hope this clarifies!