Skip Navigation

[Resolved] Can't use custom field image URL as div background image using HTML

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Shane 7 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#394724
home ceu landing goal.png
home ceu landing html error.png

I am trying to: use a custom field (image URL) as the background image for a div.

I visited this URL: hidden link

I expected to see: the image used as the div background as noted in the HTML (and shown in the first image)

Instead, I got: an error in the code which isn't pulling in the custom field URL, instead pulling in the shortcode used.

Here is the HTML I have in a widget area for the landing page hidden link

This pulls all other custom fields into the landing page, but not the custom field "Background Image URL" we want to use as the background image for a div.

I managed to get the background image working if I used an image uploader custom field, but then I can't style it with CSS the we need it to in order to accommodate the content and the height of the background.

<div class="landing-top" style="background-image:url([types field='background-image-url'][/types]);"><div class="wrap">[types field="landing-top-content"][/types]</div></div>
<div class="landing-cta1"><div class="wrap">[types field="landing-cta"][/types]</div></div>
<div class="landing-body-content"><div class="wrap">[types field="body-content"][/types]</div></div>
<div class="promo-code"><div class="wrap">[types field="promo-code"][/types]</div></div>
<div class="landing-cta2"><div class="wrap">[types field="landing-cta-2"][/types]</div></div>
<div class="course-list"><div class="wrap">[types field="landing-courses"][/types]</div></div>
#394792

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Heather,

Thank you for contacting our support forum.

Unfortunately this wont be possible 🙁 due to the changes in the wordpress shortcode API as of wordpress version 4.3.

Using a shortcode in this context wont work 🙁

Please have a look at the link below for further information on the changes in the shortcode API.
https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.