[Resolved] Elements Header Background image using CFT?

Home Forums Support [Resolved] Elements Header Background image using CFT?

Home Forums Support Elements Header Background image using CFT?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #887153
    Burt

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

    #887178
    Tom
    Lead Developer
    Lead Developer

    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.

    #887189
    Burt

    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

    #887190
    Tom
    Lead Developer
    Lead Developer

    I love filters 🙂

    Glad I could help!

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