[Resolved] Can I Assign an Element to Every Page with a Certain Parent?

Home Forums Support Can I Assign an Element to Every Page with a Certain Parent?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1516885
    Samuel

    I have a situation where I have several pages that are child pages of a certain page. I want all the child pages to use the same page header, but right now I keep adding rules to the element to cover every page. Is there a way to say that every child of a certain page should inherit a specific page header?

    #1516978
    Elvin
    Staff
    Customer Support

    Hi,

    We’ll have to use the generate_hook_element_display filter for this.

    add_filter('generate_header_element_display' , function( $display, $element_id ){
        if( $element_id === 18769 && is_page() && $post->post_parent == 18053 ){
            $display = true;
        }
        return $display;
    });

    Just replace 18769 with your Header element ID and 18053 with your parent page’s page ID.

    A wise man once said:
    "Have you cleared your cache?"

    #1518156
    Fabien

    It would be great to have it built-in too πŸ˜‰

    #1518192
    Samuel

    Thank you I will use that but would be great to have built it πŸ™‚

    #1518197
    Elvin
    Staff
    Customer Support

    Thank you I will use that but would be great to have built it

    Hi @Fabien & @Samuel,

    You can open a topic asking this as a feature request.

    Alternatively, you can raise an issue on our github page asking for it as a feature request.
    https://github.com/tomusborne/generatepress/issues

    A wise man once said:
    "Have you cleared your cache?"

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.