Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[Resolved] Page Header – Filter $id inside function 'generate_page_header_get_options'

Home Forums Support [Resolved] Page Header – Filter $id inside function 'generate_page_header_get_options'

Home Forums Support Page Header – Filter $id inside function 'generate_page_header_get_options'

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #480330
    Haris

    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

    #480406
    Leo
    Staff
    Customer Support
    #483277
    Haris

    Hello 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.

    #483718
    Tom
    Lead Developer
    Lead Developer

    Interesting idea, Haris! Let me play with filtering that $id variable – I think that should work.

    Will update you πŸ™‚

    #483733
    Haris

    Sounds 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. πŸ™‚

    #483746
    Tom
    Lead Developer
    Lead Developer

    I 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 πŸ™‚

    #494121
    Haris

    Hello, I was wondering if there any update on this, since I am planning to incorporate it in my current project.

    Thanks

    Haris

    #494527
    Tom
    Lead Developer
    Lead Developer

    I’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;
    } );
    #494666
    Haris

    Great, thanks! I will add it right away in my project.

    #494893
    Tom
    Lead Developer
    Lead Developer

    Awesome – thanks for the suggestion!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.