Skip Navigation

[Résolu] Set Div body class with custom field

This support ticket is created Il y a 3 années et 2 mois. 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.

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

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 réponses, has 2 voix.

Last updated by seanN-5 Il y a 3 années et 2 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#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: Anglais (English ) Chinois simplifié (简体中文 )

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.