[Support request] Exclude all childrens of pages

Home Forums Support [Support request] Exclude all childrens of pages

Home Forums Support Exclude all childrens of pages

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2151664
    Gautier

    Hi GeneratePress team !

    I have a custom post type, for the example : mydomain.com/review/

    I have a specific design for all reviews pages. And the childrens pages of reviews have also a specific design. The two design are completly different.

    mydomain.com/review/one
    mydomain.com/review/two
    mydomain.com/review/three

    But for SEO and structure, I add childrens to their pages like this :

    mydomain.com/review/one/how-to-do-x
    mydomain.com/review/one/how-to-choose-x

    mydomain.com/review/two/where-is-xx
    mydomain.com/review/two/what-is-xx

    Etc..

    The problem is, I need to exclude all childrens pages of each review in my specific design (element of generatepress) manually.

    Can you add the possibility to exclude the children like this ?

    Sorry for my english, not the best cause I’m french :p

    #2151754
    David
    Staff
    Customer Support

    Hi there,

    you can try using this PHP Snippet to disable the Element on a Child page:

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

    Where it says 100 you need to replace that with the ID of your Element.

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