Skip to content

Instantly share code, notes, and snippets.

@sarvar
Created November 27, 2016 07:28
Show Gist options
  • Save sarvar/4c1283da434eeb900bcf71eebab54cf7 to your computer and use it in GitHub Desktop.
Save sarvar/4c1283da434eeb900bcf71eebab54cf7 to your computer and use it in GitHub Desktop.
How to customize a divs background dynamically using Advanced Custom Fields
<div <?php if ( get_field('field_name') ) { echo 'style="background-image: url(' . get_field('field_name') . ')"'; } ?> class="hero container">
<h2>I Need a Hero</h2>
<p>I'm holding out for a hero 'til the end of the night</p>
</div>
source: http://www.endocreative.com/how-to-empower-clients-to-easily-customize-background-images/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment