|
custom SELECT field with dynamic data
Started by: Luciana
in: Toolset Professional Support
Quick solution available
Problem:
The problem here is that the user wanted to dynamically populate their select field with the information of another post type.
Solution:
This can be done by using the function below.
// Put the code of your snippet below this comment.
add_filter( 'wpt_field_options', 'func_dynamic_populate', 10, 3);
function func_dynamic_populate( $options, $title, $type ){
switch( $title ){
case 'winery-select': //select field slug goes here
$options = array();
$args = array(
'post_type' => 'wineries',
'post_status' => 'publish');
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
This can be added to your Toolset Custom code section at Toolset -> Settings -> Custom Code.
Relevant Documentation:
For further information on this code you can have a look at our documentation below.
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
|
|
2 |
8 |
3 years, 12 months ago
Luciana
|
|
Custom fields are not updated
Started by: jorge-ivanH
in: Toolset Professional Support
Quick solution available
Problem:
The problem here is that the user's WYSIWYG fields aren't being updated.
Solution:
This was a known issue and has since been resolved in our latest version of Types.
The update can be downloaded from the link below.
https://toolset.com/download/toolset-types/
|
|
2 |
3 |
3 years, 12 months ago
jorge-ivanH
|