Skip Navigation

[Resolved] I'm importing data in the site and couple of text field

This support ticket is created 6 years 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.

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 6 years ago.

Assigned support staff: Luo Yang.

Author
Posts
#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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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