Skip Navigation

[Resuelto] How do add a $ sign and the field value to a shorcode?

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 2.32 hours from now. Thank you for your understanding.

This topic contains 3 respuestas, has 2 mensajes.

Last updated by Nigel hace 3 años, 5 meses.

Assigned support staff: Nigel.

Autor
Mensajes
#765258

How do add a $ sign and the field value to a shorcode? Currently if i put a $ in the shortcode it breaks the code. ANd if i put it in the as static text it always displays even when the field is empty.

thanks,

#765906

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

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

Screen Shot 2018-04-30 at 09.13.07.png

I'm not sure which kind of field you are trying to output, but for simple fields when you insert them using the Fields and Views button you will see an option for formatting where you can insert the $ sign, and that will generate a shortcode with a format attribute, like so:

[types field='some-number' format='$ FIELD_VALUE'][/types]
#767177

thanks for your response, though I am using advanced custom fields number field. So when i click views and fields, then i click "Load non-Types custom fields"

any thoughts?

thankyou

#767356

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

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

We don't have any options for formatting non-Types fields.

If you want to conditionally show a $ sign only when a non-Types field is not empty then you would need to wrap the whole section (the $ sign and the wpv-post-field shortcode used to output the number) in a conditional statement that first tests whether there is a value set for the number field.

See https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

If inserting via the GUI in your case the source will be the wpv-post-field shortcode, where you will have to manually add the field name once it is inserted.