[Resolved] Dynamic Hero image

Home Forums Support [Resolved] Dynamic Hero image

Home Forums Support Dynamic Hero image

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #789543
    Jonas

    Hi,

    I have one custom post that I have a featured image in, but I would like to use that image as a featured image on a separate custom post. I would like to use that link as a featured image but can not seem to find a way to do it and where, programmatically. I could change them all but it’s a few and soon I am going to change the fetured image to download the link with an API call and I asume that that would be the same place where I would do it.

    Any pointer would be appreciated,

    Kru-X

    #789566
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Would the link to that featured image change dynamically? Or will it be static?

    If so, you could try this:

    add_filter( 'generate_page_hero_background_image_url', function( $image_url ) {
        if ( ! $image_url ) {
            $image_url = 'URL TO YOUR IMAGE';
        }
    
        return $image_url;
    } );

    That function would use your fallback image if no image exists for the post.

    Let me know 🙂

    #789599
    Jonas

    Yea, it is dynamic as I have the post with the image as a relation to the one I would like to display it on, but anyway that filter would do it. I missed that one looking.

    As usual, you are a guru and have the best support I have ever come across, thanks for that.

    Kru-x

    #790108
    Tom
    Lead Developer
    Lead Developer

    Thank you! Glad I could help 🙂

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