- This topic has 17 replies, 3 voices, and was last updated 5 years, 5 months ago by
Tom.
-
AuthorPosts
-
July 11, 2018 at 3:17 am #620903
George
Just experimenting with the new 1.7 beta custom header element and came to a point where I would like to conditionally display a shortcode inside a header only on certain pages. The actual hero page header that includes the shortcode has already display contitions set. I just want the shortcode that resides inside the header text not to be displayed on single post items. Right now I have to create two identical headers, one with the shortcode included and one with the shortcode excluded and assign them different conditionals. Is there a way to hook content into the custom page header somehow? Or would it make sense to consider adding the possibility to be able to write PHP code inside the custom page header element in a future release?
July 11, 2018 at 11:10 am #621327Tom
Lead DeveloperLead DeveloperHey George,
I’m not 100% sold on allowing PHP inside Page Heros. To be honest, I’m not 100% sold on it in Hooks either. Still thinking about the best road to take there.
Right now the Page Hero is filterable (in beta.2), so we would be able to filter in your code quite easily.
I’ll also look at adding a hook into the Page Hero, as I think that would be very helpful 🙂
July 11, 2018 at 11:20 am #621340George
I trust you 100% that you will find the best solution possible, Tom! Thank you.
July 11, 2018 at 8:37 pm #621617Tom
Lead DeveloperLead DeveloperTried the hook method today, it didn’t work along with the filterable element method.
I think being able to filter it is a better idea, as it will allow for custom markup. Remind me when beta.2 comes out and I’ll write up some code for you 🙂
July 12, 2018 at 1:05 am #621725George
Ok Tom, thanks. Meanwhile I used this addon to add if shortcodes and used one of those conditionals in the hero header. It worked fine.
[if is_single=no]Content here.[/if]
July 12, 2018 at 9:10 am #622150Tom
Lead DeveloperLead DeveloperCool! Is that a plugin?
July 19, 2018 at 9:34 am #627643George
Yeah, sorry, it’s this one. Hasn’t been updated for 3 years though, you think it’s safe?
July 19, 2018 at 10:20 am #627700Tom
Lead DeveloperLead DeveloperLooks pretty simple code-wise. However, I wouldn’t stop searching for a more recent one as time goes on.
July 19, 2018 at 11:09 am #627741George
Ok thanks for having a look! Would the new beta 3 header hooks be able to also address the issue?
July 19, 2018 at 7:53 pm #627991Tom
Lead DeveloperLead DeveloperHooks themselves accept PHP, but the Page Heros won’t.
July 20, 2018 at 5:57 am #628274George
You can hook content inside the page hero now though, right?
July 20, 2018 at 9:13 am #628469Tom
Lead DeveloperLead DeveloperNo, there are no hooks inside the Page Hero.
However, the entire element is filterable, so you can add elements into it/change the elements that are displayed by default.
April 12, 2020 at 5:21 pm #1236701George
Sorry to come back to this after almost two years, lol! In what way can a header element be filtered?
April 13, 2020 at 4:05 am #1237068David
StaffCustomer SupportThe entire element is filterable – Tom provides the basics here for filtering the hero html within:
https://generatepress.com/forums/topic/inside-hero-hook/#post-927610
April 13, 2020 at 11:22 am #1237694George
Ok, I see.
I am trying to enter a shortcode like this:
https://gist.github.com/quantumleap33/ef77205bddc55e74be7822c7cecd2e8ebut the shortcode is not displayed.
I have also tried that:
https://gist.github.com/quantumleap33/0c4112d1b8070550583295e6e454a7efbut the shortcode displays as text.
-
AuthorPosts
- You must be logged in to reply to this topic.