Skip Navigation

[Resolved] Styling Field Labels

This support ticket is created 2 years, 10 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
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: Africa/Casablanca (GMT+01:00)

Tagged: 

This topic contains 9 replies, has 3 voices.

Last updated by jonathanR-5 2 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#2098561

Hello, is there a way to do this now? https://toolset.com/forums/topic/show-field-label-2/
I'm using the shortcode method and want to bold the labels like "Research and Teaching Interests:" here: hidden link

#2099073

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

That linked thread covers a few aspects of a problem, what exactly is it that you need to be able to do.

If you are outputting a Types field using a shortcode you can just preface the field with a hard-coded label using strong tags or some CSS styling.

Can you clarify where and how you are outputting the field? (If you were using the block editor, for example, you'd need a different approach when using the Single Field block to output the field value.)

#2099361

I'm using the following shortcodes for example:
[types field='address' show_name='true'][/types]
[types field='phone' show_name='true'][/types]
[types field='email' show_name='true'][/types]

I need to bold some of the labels (i.e. "Address", "Phone" etc.) but looking at the source code, it's not possible to isolate the label field with CSS since the label and field text are both surrounded by one <p> tag. I didn't find a way to do this via block editor, to dynamically generate the labels with the field text.

#2099383

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello there! If you don't mind, I'll continue with you on this ticket. What about adding a the labels manually, and hiding it from the shortcode. Something like:

<p><strong>Address:</strong>[types field='address' show_name='false'][/types]</p>
<p><strong>Phone:</strong>[types field='phone' show_name='false'][/types]</p>
<p><strong>Email:</strong>[types field='email' show_name='false'][/types]</p>

Or something like:

<dl>
      <dt><strong>Address:</strong></dt>
      <dd>[types field='address' show_name='false'][/types]</dd>

      <dt><strong>Phone:</strong></dt>
      <dd>[types field='phone' show_name='false'][/types]</dd>

      <dt><strong>Email:</strong></dt>
      <dd>[types field='email' show_name='false'][/types]</dd>
</dl>

Notice the  show_name='false' attribute in the types shortcode.

I hope this helps. Let me know if you have any questions.

#2099467

I don't want to do it that way because if a field is empty, I don't want the label to show up. So, the labels need to be dynamically generated with the field value.

#2099945

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Unfortunately, that's the only way to have more control over the generated markup. You can wrap it inside conditional shortcodes to only display it when the field has a value.

<p>
    [wpv-conditional if=( ( $(wpcf-address) ne '' ) )]
        <strong>Address:</strong>
        [types field='address' show_name='false'][/types]
    [/wpv–conditional]
</p>

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-conditional
Notice the prefix "wpcf-" inside the conditional shortcode.

#2102557

Thanks but it doesn't seem to be working, the word Address shows up even when there is no address and the closing shortcode tag is also appearing [/wpv–conditional]. See this page as an example: hidden link

I'm using the code you provided:

[wpv-conditional if=(( $(wpcf-address) ne ''))]
Address:
[types field='address'][/types]
[/wpv–conditional]

#2103983

I still need assistance!

#2104585

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I would say, there is a copy/paste issue. Otherwise, the closing shortcode [/wpv–conditional] would not appear on the frontend.

Can I log in to your website and check this further? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2104957

Thank you! It was a copy paste issue.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.