[Resolved] Hook for page and all subpages

Home Forums Support [Resolved] Hook for page and all subpages

Home Forums Support Hook for page and all subpages

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #994422
    Michal

    Hello,
    is there any way to display the hook on the parent page and all the subpages of this parent page automatically?

    In display rules section I can choose only concrete pages one by one.

    #994722
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This topic might help: https://generatepress.com/forums/topic/conditionally-display-hook-on-sub-page-of-parent/

    For example:

    add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
        global $post;
    
        if ( 1180 === $element_id && ( is_page() && $post->post_parent == '415' ) ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );

    You need to replace 1180 with the ID of your Element, and 415 with the ID of the parent page.

    #994788
    Michal

    Great it works perfectly ๐Ÿ™‚

    #995021
    Tom
    Lead Developer
    Lead Developer

    Awesome ๐Ÿ™‚

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