Skip Navigation

[Resolved] Custom field output as HTML attribute

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.

This topic contains 2 replies, has 2 voices.

Last updated by giuliaS 5 years, 8 months ago.

Assigned support staff: Minesh.

Author
Posts
#302753

Hi, I need to use a custom field as HTML attribute. I'll try to explane:
I have a post with a color picker custom field. I want to use the output of this custom field as a backgrounfd color for a <div> element inside View plugin.
If i write something as:

<div style="background-color: [wpv-post-field name=??box-color??]">

it doesn't work. Can you help me please?

Same problem if I'd like to use the post link as target of the HTML <a> attribute.

#302878

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

You should use types shortcode to get value of your custom field.
For example:

[types field="url"][/types]

Please refer following link for types API:
=> https://toolset.com/documentation/functions/

I'd like to use the post link as target of the HTML <a> attribute.
=> For this you should use shortcode [wpv-post-url].

Please refer following link for more information:
=> https://toolset.com/documentation/views-shortcodes/#wpv-post-url

#303354

Thanks a lot! Now it works!