Home › Forums › Support › Page Header – Filter $id inside function 'generate_page_header_get_options'
- This topic has 9 replies, 3 voices, and was last updated 6 years, 2 months ago by Tom.
-
AuthorPosts
-
January 26, 2018 at 4:03 am #480330Haris
HEllo
First of all, I love GeneratePress for its simplicity and developer friendliness.
I am trying to assign Page Headers in a dynamic way, so that I can render a Page Header based on conditions.
For example, I want to show a specific Page Header for Posts that belong to a specific category.
Looking into the code, I could accomplish that if there was a filter for the $id variable value, inside the file gp-premium/page-header/functions/functions.php, somewhere around line 200.
This way, I could check my conditions and filter the desired Page Header ID.
Any clues? Could you add this filter?
Is there any other way to accomplish what I am describing above?
Thanks
Haris
January 26, 2018 at 6:39 am #480406LeoStaffCustomer SupportHi there,
I believe this si what you are looking for: https://docs.generatepress.com/article/adding-page-headers-taxonomies/
January 30, 2018 at 12:54 am #483277HarisHello and thanks for the reply.
I am afraid that this is not what I am looking for.
The article describes how to apply to apply a Page Header on an archive page itself.
What I need to accomplish is to apply a Page Header to all Posts that belong to a certain term (not the term page itself).
Also, in order to make my clients’ life easier, I would like to be able to apply Page headers automatically for Pages as well. For example, I would like to apply a certain Page Header to all pages that have a specific parent page (or some other logic).
Is there a way to do it via a filter?
It would be very convenient to be able to do it dynamically via code.
Thanks in advance.
January 30, 2018 at 9:15 am #483718TomLead DeveloperLead DeveloperInteresting idea, Haris! Let me play with filtering that $id variable – I think that should work.
Will update you π
January 30, 2018 at 9:26 am #483733HarisSounds great and really happy you are considering this because this would give great power on manipulating page headers and making clients’ life much easier.
If by any chance you could update me on this even before you release it in the next version, it could make me super happy, since I am actively working on a project and I would rely on it.
PS: I am assuming here that a simple filter call is enough around line 200, but you know better. π
January 30, 2018 at 9:39 am #483746TomLead DeveloperLead DeveloperI will for sure – I’ll try to find a minute to play with it today. It should be as simple as adding a filter on that line π
February 12, 2018 at 12:53 am #494121HarisHello, I was wondering if there any update on this, since I am planning to incorporate it in my current project.
Thanks
Haris
February 12, 2018 at 9:03 am #494527TomLead DeveloperLead DeveloperI’ve included it in GPP 1.6, which should be available this month.
This will be the usage:
add_filter( 'generate_page_header_id', function( $id ) { if ( is_page( 'about' ) ) { return 17686; // ID of the Page Header to use. } return $id; } );
February 12, 2018 at 11:35 am #494666HarisGreat, thanks! I will add it right away in my project.
February 12, 2018 at 8:20 pm #494893TomLead DeveloperLead DeveloperAwesome – thanks for the suggestion!
-
AuthorPosts
- You must be logged in to reply to this topic.