Site logo

Archived topic

Elements site header for all sub pages

5 replies · Started by Damiaan van Vliet on November 15, 2019

Viewing posts 1–6 of 6

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 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 :)

This archived topic is closed to new replies.