Skip Navigation

[Resolved] Set Div body class with custom field

This support ticket is created 5 years, 3 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by seanN-5 5 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1331931

I am trying to add a class to a <div> using a custom field.

Here is the code I am trying:

<div class="[wpv-post-field name='performance-ed-class']">[types field="end-date"][/types]</div>

This is what I am getting... no class added: <div class="">September 4, 2019</div>

#1331997

Hello,

I assume the custom field "performance-ed-class" is created with Types plugin, Types will add pre-fix "wpcf-" before the field slug, so you can modify your codes as below:

<div class="[wpv-post-field name='wpcf-performance-ed-class']">[types field="end-date"][/types]</div>

And test again

#1332025

My issue is resolved now. Thank you!

Luo, thanks for the fast response. I found another solution to what I was trying to do (hide a field is a certain post type). I wound up using the conditional logic to say if is post type A then hide. I'm going to duplicate the view and try your solution as well.