Skip Navigation

[Resolved] Set Div body class with custom field

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.

Our next available supporter will start replying to tickets in about 6.99 hours from now. Thank you for your understanding.

This topic contains 2 replies, has 2 voices.

Last updated by seanN-5 1 year, 7 months ago.

Assigned support staff: 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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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.