Skip Navigation

[Resolved] How to show a custom field NAME (not value) dynamically

This support ticket is created 4 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 4 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1527281

Tell us what you are trying to do? In my content template I want to know be able to enter a shortcode which will display a custom field NAME dynamically.

My field names are very long, and they also represent a question. The 'value' of the field is the answer to the question. If I change a custom field name (ie I need to change the question), I don't want to have to type this in manually into my content template, otherwise that means I need to change things twice. Surely I should be able to just dynamically load the field name, and then also separately be able to dynamically load the field value? Thanks for your help 🙂

Is there any documentation that you are following? I am looking at this page but it seems to suggest that this is not possible = https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-field

Is there a similar example that we can see? No

What is the link to your site? Supplied above

#1527603

Hi, it really depends on the type of field. In general, the Views shortcode wpv-post-field is designed for displaying the raw field value stored in the database. If you want to display the field name instead, the Types shortcode is more appropriate. Depending on the type of field it is, it may or may not be possible with the shortcodes provided by Types. A Numeric field name, for example, can be displayed as shown here, but some other fields do not provide this format option:

[types field="my-number" format="FIELD_NAME"][/types]

Examples of shortcodes for the different field types are included here: https://toolset.com/documentation/customizing-sites-using-php/functions/
Click "+ More" below any field type to show several examples of post fields, user fields, term fields, and their PHP equivalents. There is a bug right now in the documentation and shortcode tags are displayed as curly braces {{ }} instead of square braces [ ], so be aware when copy + pasting you may need to replace those characters. Our documentation team is aware of this problem and hopes to fix it soon.

If you have a question about a specific field type, let me know.