Skip Navigation

[Resolved] Layout cell background image from custom field

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use an image specified in a custom field as the background of a layout cell.

Solution: Add the background image as an inline style to the container:

<div style="background-image:url('[types field='layout-ricordo' size='full' url='true'][/types]')">
This support ticket is created 6 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 2 voices.

Last updated by Christian Cox 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#627684
background-cell1.png
background-cell.png

in the layout cell I call the various fields with this code to form a card

<p class="titolo-creatura">[wpv-post-title]</p>
<div class="prima-foto">[wpv-post-featured-image size="custom" width="500"]</div>
<p class="dedica">[types field='dedica'][/types]</p>
<p class="dedica-seconda">[types field='dedica-seconda'][/types]</p>
<p class="data-decesso">[types field='data-decesso'][/types]</p>

I want to use a background image that is chosen by a radio field (name field= layout-ricordo) , I added this code:

<p>background: url("[types field='layout-ricordo' size='full' url='true'][/types]")</p>

the final code is this:

<p>background: url("[types field='layout-ricordo' size='full' url='true'][/types]")</p>
<p class="titolo-creatura">[wpv-post-title]</p>
<div class="prima-foto">[wpv-post-featured-image size="custom" width="500"]</div>
<p class="dedica">[types field='dedica'][/types]</p>
<p class="dedica-seconda">[types field='dedica-seconda'][/types]</p>
<p class="data-decesso">[types field='data-decesso'][/types]</p>

you see the small background in the upper right corner - URL: hidden link

where am I wrong?

#627716

sorry, see the background on the top left

#627824

I am going crazy !!!

are hours that I try in many ways, because no one helps me ???

#627829

in this guide: https://toolset.com/documentation/getting-started-with-toolset/create-templates-to-display-custom-posts/

It is told: " If your theme comes with a page builder, you should use it instead of Layouts. Toolset is already compatible with some of the most popular page builders."

in my Ocean WP theme elementor is used, can you tell me HOW to create a layout for post typos?

thank you

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/split-how-to-create-content-templates-with-elementor/

#628075

Hi, sorry we were short on staff at the end of the week and we are trying to catch up on the backlog now.

I want to use a background image that is chosen by a radio field (name field= layout-ricordo)
You should add the background URL style to a wrapping element like this:

<div style="background: url('[types field='layout-ricordo' size='full' url='true'][/types]')">
  <p class="titolo-creatura">[wpv-post-title]</p>
  <div class="prima-foto">[wpv-post-featured-image size="custom" width="500"]</div>
  <p class="dedica">[types field='dedica'][/types]</p>
  <p class="dedica-seconda">[types field='dedica-seconda'][/types]</p>
  <p class="data-decesso">[types field='data-decesso'][/types]</p>
</div>

I have split your question about Elementor into a separate ticket and I will follow up with you there.

#628234
step6.png

think it's a writing error, see screenshot

#628430
step8.png

my doubt is if I wrapped the shortcode correctly.

I did that. tell me if it's correct
(I'd like to do it myself and understand more about the toolset shortcode)

<div class="contenitore">
<div class="layout-creatura" style="background-image:url('[wpv-post-field name='wpcf-layout-ricordo']');">
<div class="titolo-creatura">[wpv-post-title]</div>
<div class="prima-foto">[wpv-post-featured-image size="custom" height="300"]</div>
<div class="dedica">[types field='dedica'][/types]</div>
<div class="dedica-seconda">[types field='dedica-seconda'][/types]</div>
<div class="data-decesso">[types field='data-decesso'][/types]</div>
</div>
</div>

is this a good solution too?

<div class="contenitore">
<div class="layout-creatura" style="background:url('[wpv-post-field name='wpcf-layout-ricordo']')">
<p class="titolo-creatura">[wpv-post-title]</p>
<div class="prima-foto"> [wpv-post-featured-image size="custom" height="300"]</div>
<p class="dedica">[types field='dedica'][/types]</p>
<p class="dedica-seconda">[types field='dedica-seconda'][/types]</p>
<p class="data-decesso">[types field='data-decesso'][/types]</p>
</div>
</div>

front-end result: see attached image

I wanted to know from you how you would write the layout

thanks

#628441

It's probably better to use div tags because if your custom field content contains another p tag, that will cause invalid HTML. You cannot nest a p inside another p.

#628687

I wanted to ask you one last thing and then close the post.

1) as you can see I put a div = "container" but in practice it is only a CSS
     because it is the container or box of everything: writing, background image. then I declare values in the css. question: correct like this?

2) the shortcode that you have recommended to me is different from what I entered using layout, why this difference?

[wpv-post-field name='wpcf-layout-ricordo']
[types field='layout-ricordo' size='full' url='true']
#628889

1) as you can see I put a div = "container" but in practice it is only a CSS
because it is the container or box of everything: writing, background image. then I declare values in the css. question: correct like this?

I'm sorry, I don't understand the question. If the styles show up as expected, then the code is probably correct.

why this difference?

[wpv-post-field name='wpcf-layout-ricordo']
[types field='layout-ricordo' size='full' url='true']

wpv-post-field shortcode is a shortcut to get the raw data from the field without any formatting.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-field
https://toolset.com/documentation/customizing-sites-using-php/functions/#image