Skip Navigation

[Resolved] Populating select field and storing value as meta custom fields value

This support ticket is created 5 years, 1 month 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 4 replies, has 2 voices.

Last updated by philippeK 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1590957

Hello
I would like to be able to populate a select custom field programmatically with php WITHOUT using the wpt_field_options hook. Simply add the value with php as I would do it by hand on your edit group. So these values need to be store on the wordpress DB.
The reason why I can't use wpt_field_options : I use Admins Columns and if I populate my select values with item the admins columns won't let me inline edit the values as it can find them on the DB.
Or maybe there is an another way ?

#1591629

There's nothing exactly like this available in our PHP API. The wpt_field_options API isn't ideal because options added with this filter are not available in custom searches. The only other way to manipulate select field values is to export that field using Types export, then manipulate the exported XML file to include the new options, then reimport that XML file using Types import.

#1591631

ok, thanks
and also wpt_field_options is called on every page front or backend, so I had to put a :
if (!is_admin()) {
return "";
}
to not do some extensive BD work on every page as I simply need it to show on the edit page of my custom post type.

Can I export only one custom field ?
Can I import only one custom field back ?

#1592011

Can I export only one custom field ?
No, the export file generated by Types is not customizable and it contains all custom post type, custom field, custom taxonomy, and post relationship structure information.

Can I import only one custom field back ?
During the import process you have the ability to deselect fields, taxonomies, relationships, and post types you do not want to import. It's a bit tedious because there is no "deselect all" or "select all" feature. It's probably more practical to delete all the irrelevant data from the XML file before importing.

#1595259

My issue is resolved now. Thank you!