Archived topic
Elements site header for all sub pages
5 replies · Started by Damiaan van Vliet on November 15, 2019
Good morning great team,
Is it possible to have a element "site header" which I created also to be displayed not only on one page but also to the sub pages of that page?
So that I don't have to choose all sub pages at the Display Rules option?
E.g. a site header for "about us" and it should also be displayed on the sub pages.
Home (site header 1)
About Us (site header 2)
-sub page 1 (site header 2)
-sub page 2 (site header 2)
-sub page 3 (site header 2)
Thanks!
Hi there,
This topic might be worth checking out: https://generatepress.com/forums/topic/gp-hook-on-certain-child-pages/#post-1056464
Let me know :)
Hi Tom, thanks for reply. The code looked promising, but when I tried it it did not help.
Link to site, I used the code for the "trainingsmolen" banner.
/* trainingsmolen banner ID 2681 and trainingsmolen page ID 1691 and subpages */
add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
global $post;
if ( 2681 === $element_id && ( is_page() && 1691 == $post->post_parent ) ) {
$display = true;
}
return $display;
}, 10, 2 );
What if you use the generate_header_element_display filter instead of generate_hook_element_display?
Yes Tom, that's the solution. Thank you.
You're welcome :)