[Resolved] Posts Header Inside Content Area (Left of the Side Bar)

Home Forums Support [Resolved] Posts Header Inside Content Area (Left of the Side Bar)

Home Forums Support Posts Header Inside Content Area (Left of the Side Bar)

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #748299
    Eric

    I setup a header in Elements so that my post title overlays the featured image, but I want to keep that featured image contained in the content area, to the left of the side bar, not above it. Is it possible to change the location of the header? I’ve read a few older posts in the forums on this subject but I’m checking to see if there is an update.

    #748927
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Currently, this isn’t possible.

    However, I’m considering adding a filter in GPP 1.8 that would allow for this.

    If you’re interested in trying it out, you could do this:

    1. Open wp-content/plugins/gp-premium/elements/class-hero.php and find this line:

    add_action( 'generate_after_header', array( $this, 'build_hero' ), 9 );

    2. Replace it with this:

    $location = apply_filters( 'generate_page_hero_location', 'generate_after_header', $post_id );
    
    add_action( $location, array( $this, 'build_hero' ), 9 );

    3. Then you could add a custom function like this:

    add_filter( 'generate_page_hero_location', function() {
    	return 'generate_before_content';
    } );
    #749136
    Eric

    Ok thanks, I’ll try that. Where do I insert that custom function? In the class-hero.php file? I’m a novice with this stuff.

    #749215
    Tom
    Lead Developer
    Lead Developer

    The custom function can be added using one of these methods: https://docs.generatepress.com/article/adding-php/

    #752362
    Eric

    That worked perfectly, thank you!

    #753026
    Eric

    I spoke too soon, I do have one more question, sorry!

    I’ve replaced the code in class-hero and added the custom function to move my page hero from above the content to within the content …

    Is it possible to make the page hero (featured image) span the entire width of the content area? … Meaning ignore the content padding? I’ve been playing around with Word Press 5.0 and I see that you can make images “wide”. I want to do that same thing with the page hero / featured image.

    I posted an example of the wide image here:
    http://www.ericsturgeon.com/2018/12/10/this-is-just-a-test/

    Thanks,
    Eric

    #753153
    David
    Staff
    Customer Support

    Hi there,

    you can try this CSS, which does what the Block editor does to make an image full width:

    .page-hero {
        margin-left: -50px;
        margin-right: -50px;
    }

    The 50px is the container padding that you have set.

    #753323
    Tom
    Lead Developer
    Lead Developer

    Alternatively, you can try this hook: generate_before_main_content

    #908346
    Eric

    Hi Tom,

    I still have version 1.7.8 and haven’t yet upgraded to 1.8.2. After I upgrade, will I need to edit the class-hero.php file the same way that you advised in order to display my featured image w/ title overlay within the content area as opposed to above it?

    #908678
    David
    Staff
    Customer Support

    Hi there,

    looks like Tom included the filter within 1.8 so no need to edit the class-hero.php

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