Tell us what you are trying to do?
-Create a select dropdown in a CRED user create/edit form that is dynamically populated with the terms from my custom taxonomy "Regions". This is so users can select a region and only see content that relates to it.
Is there any documentation that you are following?
I have tried to implement this, but in my scenario it doesn't appear to work- just breaks my field- see screenshot (unless i've misunderstood the code): https://toolset.com/forums/topic/i-wish-i-could-load-a-custom-select-with-options-from-a-custom-taxonomy/
Thanks in advance for any assistance!
Hello,
The thread you mentioned above is outdated, it is different in the latest version of WordPress, you can try these:
1) Create a custom select user field, field title is "My Regions"
2) Create a custom taxonomy "Regions", the taxonomy slug is "regions"
3) Modify your PHP codes as below:
add_filter( 'wpt_field_options', 'fill_select', 10, 3);
function fill_select( $options, $title, $type ) {
if ($title == 'My Regions') {
$options = array();
$args = array(
'taxonomy' => 'regions',
'hide_empty' => false,
);
$terms = get_terms( $args );
foreach ($terms as $term) {
$options[] = array(
'#value' => $term->term_id,
'#title' => $term->name
);
}
}
return $options;
}
And test again.
More help:
https://developer.wordpress.org/reference/functions/get_terms/