Archived topic
Is it possible to detect whether a page/post title is hidden and hide GP header
3 replies · Started by mrwebsites on May 16, 2020
I am hoping that there is a php snippet that I can use to detect whether the title has been turned off (or on) on a page, and then return that in a GP header. That way showing the title in the header is optional.
If it is turned off in the page editor, it will be hidden in the header. Otherwise it will show.
Hi there,
Tom provides the info here:
https://generatepress.com/forums/topic/conditional-test-for-disabled-elements/#post-424225
Thanks Dave!
That's definitely a step in the right direction. I can conditionally show html almost anywhere on the page based on the title being disabled or not. But not inside the GP Header element, it seems.
Does the GP Header element have a hook? I am trying to show or hide the title of the page in the GP header, based on the pages title being disabled or not.
I cannot run php inside the GP Header element. I cannot use a hook to target the GP Header element. Any advice on how I can do this?
Is there any other content in the Hero?
If there is none then you could use that condition with the generate_page_hero_output filter.
Example of that filter being used here:
https://generatepress.com/forums/topic/write-php-inside-custom-page-headers/page/2/#post-1237983
If that doesn't work i can check with Tom - he's bound to have something up his sleeve.