Site logo

Archived topic

Elements Header Background image using CFT?

3 replies · Started by Burt on May 2, 2019

Viewing posts 1–4 of 4

Is there any way to use a custom field type as a background image in Elements header?

Hi there,

For sure, try this:

add_filter( 'generate_page_hero_background_image_url', function( $url, $options ) {
    if ( 123 === $options['element_id'] ) {
        $field = get_post_meta( get_the_ID(), 'your_custom_field_name', true );

        if ( $field ) {
            $url = $field;
        }
    }

    return $url;
}, 10, 2 );

You just need to replace 123 with the element ID you're targeting, and your_custom_field_name with the name of your custom field.

Awesome Tom - I'm thinking you have a filter on every section (-; Tried looking for it in the dev filters but didn't see - had a suspicion you would have a hero filter for elements

Thx a million
runner2009
Burt Gordon

I love filters :)

Glad I could help!

This archived topic is closed to new replies.