- This topic has 17 replies, 3 voices, and was last updated 1 year, 6 months ago by Tom.
July 11, 2018 at 3:17 am #620903George
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?GeneratePress 2.1.3July 11, 2018 at 11:10 am #621327TomLead DeveloperLead Developer
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 #621617TomLead DeveloperLead Developer
Tried 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 #622150TomLead DeveloperLead DeveloperJuly 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 #627700TomLead DeveloperLead DeveloperJuly 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 #627991TomLead DeveloperLead DeveloperJuly 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 #628469TomLead DeveloperLead Developer
No, 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 #1237068DavidStaffCustomer Support
The entire element is filterable – Tom provides the basics here for filtering the hero html within:April 13, 2020 at 11:22 am #1237694George
Ok, I see.
I am trying to enter a shortcode like this:
but the shortcode is not displayed.
I have also tried that:
but the shortcode displays as text.
- You must be logged in to reply to this topic.