The code mentioned here - https://toolset.com/forums/topic/using-category-taxonomy-as-select-option/ didnt' work in the latest toolset and I was unable to ask question in the same thread.
Can you please provide the new/updated code.
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
Let me try this on a test site and check whether it still works and see what needs to change if not.
You want to populate the options when you are editing the Types field of a post in the back-end admin screens, is that right?
Yes, i want populate the options in select from custom taxonomy term.
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
I looked at the code in the linked post and there is a simple error which would prevent it from working, in the final line it needs to return the $options variable.
The updated code therefore looks like this:
add_filter( 'wpt_field_options', 'tssupp_fill_select', 10, 3);
function fill_select( $options, $title, $type ) {
if ($title == 'My select field') {
$options = array();
$args = array('hide_empty' => 'false');
$terms = get_terms( array('my-taxonomy'), $args );
foreach ($terms as $term) {
$options[] = array(
'#value' => $term->term_id,
'#title' => $term->name
);
}
}
return $options;
}
You need to edit it for the name of your select field as well as the taxonomy.
Do you want to try that and let me know how you get on?
Thank you Nigel.
You forget to change function name "fill_select" so i changed it and code working fine.
Thank you for exact code.
This code is working fine outside of repeatable field group. But it is not working inside repeatable field group.
Can you please help me with the changes that needs to be done in the hooks so that it starts working inside repeatable field group.