Archived topic
Elements - Set Up Display Rule to Show only a Parent Page and its Children
5 replies · Started by Jonathan on March 24, 2023
Hi there,
I'm hoping there's an easy solution here. My goal is to set up a Layout in Elements that hides the primary navigation on a Parent page and the children of that parent page. I could do this manually by adding each individual page, but I'd prefer to set this up dynamically.
Is there a simple way to do this or do I have to collect every single page?
Hi there,
I believe this is what you are looking for:
https://docs.generatepress.com/article/generate_element_display/#display-an-element-to-a-parent-page-and-all-child-pages
Let me know :)
That worked like a charm! Is there a way to set Exclusions in the same way? For example, I have a block that I want to display on the entire site EXCEPT for one parent page and its children.
Hi there,
you would set the elements display rules to the entire site.
Then using that same PHP snippet change the $display = true; to $display = false;
So when the condition is met it will remove the element.
Nailed it. Thanks all!
Glad to be of help!