Skip Navigation

[Résolu] I'm importing data in the site and couple of text field

This support ticket is created Il y a 7 années et 7 mois. 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 réponses, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 7 mois.

Assisted by: Luo Yang.

Auteur
Publications
#431422

Hi on my site I'm importing the data, and couple of text field and multi-line field are set for default value and I'm trying to view them on front-end but I can't see them unless I go on every page of post type and update the page.

Since I'm importing data for post type I can't go on each and every page and update them individually.

So I'm looking for a solution that I can't show my default value for the text-field without going to each and every page and update them in .php

Thanks looking forward for your answer.

#431644

Dear laura,

I suggest you try with Views shortcode [wpv-conditional] to check if the custom field is empty, display the default value, if the custom field isn't empty, display the field value, for example, there is a custom single line field "test-field":

[wpv-conditional if="( empty($(wpcf-test-field)) )"]
This field is empty or does not exist, display the default value
[/wpv-conditional]
[wpv-conditional if="( empty($(wpcf-test-field)) )" evaluate="false"]
here display the field value:
[types field="test-field"][/types]
[/wpv-conditional]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional

#433850

what would I write instead of

This field is empty or does not exist, display the default value

is there a PHP code to display default value if the field is empty.

Thanks

#433860

You can try with wordpress function get_post_meta():
https://developer.wordpress.org/reference/functions/get_post_meta/

Check if the field value is empty, then display the default value.

#433863
Screen Shot 2016-09-07 at 10.59.44 PM.png

I meant to as with what would I be calling default text in field like there should be some kind of term for that ...

I'm attaching a screenshot for reference

#433879
1.jpg

I assume we are talking about in wordpress admin side, when user edits a post, you are going to display a default value in the input box.

If your custom fields are created with Types plugin, please edit them, there are two options you can try:
1) Placeholder: This value is being displayed when the field is empty in the post editor.
2) Default Value: This is the initial value of the field.

See screenshot 1.jpg

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