Archived topic
Targetting GP element to display on child pages of a parent page
3 replies · Started by Ben on March 8, 2023
Hi,
I have an element (javascript that hooks into wp_head) that I need to only appear on all child pages of a particular parent page.
Is there a way to set this display rule for GP elements?
Many thanks
Ben
Hi Ben,
I believe the generate_element_display filter is what you are looking for.
Take a look at the second example here:
https://docs.generatepress.com/article/generate_element_display/
Let me know if this helps :)
thanks Leo,
Does that go in functions.php ?
Hi Ben,
You can use one of the methods introduced in the below article:
https://docs.generatepress.com/article/adding-php/
If you are using a child theme, you can add the PHP code to the child theme's functions.php file.