0

I want to use meta url as background image.But the fact that I do not want to show "background-image:url('_')" this way because if my meta value is empty.What I thought to end up in this way.

$bgimage= get_post_meta( $post->ID, 'settings_image', true );
< div style="<?php echo 'background-image: url(".wp_get_attachment_url( $bgimage )")';?>">

I think this is best way since I do not want to put extra conditional block here.Did I make mistake in catenation?

1 Answer 1

0

Very slight one, see below :)

$bgimage= get_post_meta( $post->ID, 'settings_image', true ); ?>
< div style="<?php echo 'background-image: url('.wp_get_attachment_url( $bgimage ).')';?>">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.