The customer asked how the 'wpt_field_options' filter can be used to dynamically generate a long and alphabetically ordered list of options for a select type field.
Solution:
Shared some details and a code snippet example to show how this filter can be used to generate options from a custom post type:
add_filter( 'wpt_field_options', 'func_to_dynamically_populate_shop_locations', 10, 3);
function func_to_dynamically_populate_shop_locations( $options, $title, $type ){
switch( $title ){
case 'Book Shop Locations':
$options = array();
// add first empty value
$options[] = array('#value' => '', '#title' => '---');
// get all tmna-location post items
$args = array( 'post_type' => 'shop-location', 'posts_per_page' => -1, 'post_status' => 'publish','orderby' => 'title' );
$results = get_posts( $args );
if ( $results ) {
foreach ( $results as $post ) {
$options[] = array('#value' => $post->ID, '#title' => $post->post_title);
}
}
break;
}
return $options;
}
The customer had a 'checkboxes' type custom field and wanted to show/hide some other single-line fields, based on those checkboxes.
Solution:
Guided that conditional display of custom fields is not supported for the values coming from the "checkboxes" type field. So a "checkbox" type field for each checkbox/option would need to be added, separately, which can then control the display of other custom fields.
Problem:
The user would like to duplicate a custom field.
Solution:
Toolset does not have a feature of copying or duplicating a field. And because the field already exists on the field group it won't be offered on the list of already created fields.
The 2nd field needs to be created manually. Or try this workaround:
1. Rename the existing field and its slug. Check this screenshot http://prntscr.com/20ly8n1
2. Save the field group. This will remove the initial field from the group.
3. Add a new field, and choose the initial field for the list of already created fields.
The customer reported that a specific custom field group was missing from the post edit screen.
Solution:
The post field group was available, but since the section was part of the accordion, the arrow next to it needed to be clicked, in order to open/collapse it.