You can make the list dynamic, by registering a custom shortcode, that can get all the terms from a taxonomy, and then as needed, either return the comma-separated list of their IDs or titles.
For example:
add_shortcode('custom_taxonomy_items_list', 'custom_taxonomy_items_list_func');
function custom_taxonomy_items_list_func($atts) {
$return = $atts['return'];
$taxonomy = $atts['taxonomy'];
$output = array();
$terms = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
) );
foreach( $terms as $term ) {
if($return == 'title') {
$output[] = $term->name;
}
elseif ($return == 'ID') {
$output[] = $term->term_id;
}
};
return implode(',', $output);
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
Note: Please also add "custom_taxonomy_items_list" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
This new shortcode accepts two attributes:
1. taxonomy: the slug of the taxonomy to get the terms from
2. return: can be 'ID' or 'title'
Example usage:
// get the comma-separated list of titles from the 'toolset-test-tax' taxonomy
[custom_taxonomy_items_list taxonomy="toolset-test-tax" return="title"]
// get the comma-separated list of IDs from the 'toolset-test-tax' taxonomy
[custom_taxonomy_items_list taxonomy="toolset-test-tax" return="ID"]
And, these shortcodes can then be used in the select field's shortcode in the view, like this:
[wpv-control-postmeta type="select" field="wpcf-toolset-select-test-tax" source="custom" url_param="wpv-wpcf-toolset-select-test-tax" values=",[custom_taxonomy_items_list taxonomy='toolset-test-tax' return='ID']" display_values="-selectzzz-,[custom_taxonomy_items_list taxonomy='toolset-test-tax' return='title']"]
This way, the static list of options, would become dynamic too.
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/