Skip Navigation

[Resolved] Make a featured img of post as background in the div block

This support ticket is created 7 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 7 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#553799

I need to automatically make featured img of post (custom type) as div block backgroung-img - screenshot -hidden link

I tried to substitute a macros in css, but it is not processed - hidden link

Please help.

Thanks.

P.S.: Sorry for my English, maybe you have russian support?=))

#553803

You cannot use ShortCodes in CSS style sheets.
This is not possible due to the nature of the CSS language. It won't execute ShortCodes or HTML or PHP.

What you can do is use an absolute URL in the CSS.

But that won't allow you to have a dynamic background (each post with its background as set in the featured Image)

I think you should add this to your Theme with PHP.
As an example, you can edit your single.php or your single-{post-type}.php file, and add a PHP variable that populates the HTML with the Featured Image of each post.
https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post

Or, insert it directly into the HTML where you create your .apart-thrumb-wrap DIV:
https://toolset.com/forums/topic/how-to-add-a-custom-posts-featured-image-as-a-background-for-a-div-in-views/

Or, use a Plugin:
hidden link

The main problem is, in Layouts, if you add the class .apart-thrumb-wrap to a Row or Cell setting, you will not be able to use ShortCodes there.
But you can, if you add it to an HTML editor in Layouts, like a Visual Editor or Content Template.

I am not sure where you add the class, so I passed both possibilities above.

Let me know if this helps you.

Unfortunately, CSS is not to be populated with ShortCodes, neither JS.
Those are limitations of the language, not Toolset per se 🙂