Site logo

Archived topic

Page Headers: Default image if no feature image set

7 replies · Started by Altti on August 21, 2017

Viewing posts 1–8 of 8

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.

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
}

Awesome. This works just as it should.

Perfect :)

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!

Anxiously awaiting the final release of 1.7!

Us too! :)

This archived topic is closed to new replies.