Skip Navigation

[Resolved] Adding shortcode within default setting for custom field

This support ticket is created 5 years, 11 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
- 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by laurencea 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1199165

Hi,
I've created wysiwyg custom field "ovanova-text" and added a default value that includes shortcode like so:
<p>Support [types field='partner-organization'][/types] and learn what solar can do for you by sharing your contact information and choosing the most convenient time to connect with you.</p>.

However, the shortcode is being stripped out. How can we fix this?

#1199235

Hi Laurence,

Thank you for waiting.

The "cred_field" shortcode, supports a "value" attribute for setting a default value.
( ref: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field )

You can use that in your field for the editing form, like this:


[cred_field field="ovanova-text" force_type="field" class="form-control" output="bootstrap" value="Support [types field='partner-organization'][/types] and learn what solar can do for you by sharing your contact information and choosing the most convenient time to connect with you."]

For a new post form, it won't be useful to use a default value which is dependant on the value of another custom field, because it would be empty.

>> If I remove the field from the add new post form, then the
>> custom fields keeps the default value in the backend correctly.
>> If I remove the field from the edit post form, it stays correctly in
>> the backend but doesn't display on the frontend.

- When the WYSIWYG field with a default value exists in the form and it is submitted, that value is saved/stored as a fixed value and no longer remains a default value.

To avoid this, it would be better to show this default text on the top or bottom of the WYSIWYG custom field and not inside it.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1199478

My issue is resolved now. Thank you!
Problem was a colleague changed custom field slug. I scrapped the custom field and added the default text to the Elementor page template.