Archived topic
Exclude all childrens of pages
1 reply · Started by Gautier on March 12, 2022
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
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.