I am trying to set background image from meta value.I am successful also.But if the meta image is not set the out put

<div id="pricing" style="background: url('')"></div>

But I do not want to show background: url('') if there is not meta value is set.My code to get image

        $bgimage= get_post_meta( $post->ID, 'settings_image', true );
        $img=background-image: url('.wp_get_attachment_url( $bgimage ).');

To display style=""
I have tried

    if(isset($bgimage)){
    $img=background-image: url('.wp_get_attachment_url( $bgimage ).');
    }

Read more here: Setting conditional background image from meta value


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: