Support

Account

Home Forums Backend Issues (wp-admin) How to make a background image using a image field

Helping

How to make a background image using a image field

  • Hi There,

    I am trying to make a background image by using a image field however I am struggling to find anything which works I have not been able to find anything around this so any assistance will help.

    I have not put any code as I am unsure where to even start with this thanks in advance.

  • If You’re new to ACF & PHP – it’s easy.

    Step 1:
    Make ACF field: image and set “Return Format” option to “Image URL”

    Step 2:
    Let’s say You give the Label “My background” -> the (autogenerated) Name will be: my_background so:

    Now You can use it anywhere in post / page:

    <div style="background-image: url(<?php echo get_field('my_background'));">...</div>

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.