[Resolved] Page Headers: Default image if no feature image set

Home Forums Support [Resolved] Page Headers: Default image if no feature image set

Home Forums Support Page Headers: Default image if no feature image set

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #370253
    Altti

    Hi,

    Really like the theme. Is there a way to put a default background image to “Page Header” as a fallback if no feature image is selected? I tried with CSS but that overrides it also when feature image is set.

    Thanks.

    #370547
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could try something like this..

    add_action( 'wp_head', 'tu_default_page_header_bg_image' );
    function tu_default_page_header_bg_image() {
        if ( function_exists( 'generate_page_header_get_image' ) && generate_page_header_get_image( 'ALL' ) ) {
            return;
        }
    
        ?>
        <style>
            .page-header-content {
                background-image: url(URL TO YOUR IMAGE);
            }
        </style>
        <?php
    }
    #393413
    Altti

    Awesome. This works just as it should.

    #393641
    Tom
    Lead Developer
    Lead Developer

    Perfect πŸ™‚

    #623150
    Scott

    Running into this same issue on a new site. It’d make a lot of sense to be able to add a featured image to the page header itself and check a box to make the page header’s featured image the default for any post where the header appears and no featured image is set.

    I can work around with the suggestion in this thread or other ways so not an urgent need but would be a nice enhancement!

    #623197
    Tom
    Lead Developer
    Lead Developer

    Check out GPP 1.7-beta.2: https://generatepress.com/gp-premium-1-7/

    The new Page Hero option has this ability πŸ™‚

    #623223
    Scott

    Anxiously awaiting the final release of 1.7!

    #623320
    Tom
    Lead Developer
    Lead Developer

    Us too! πŸ™‚

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