Home › Forums › Backend Issues (wp-admin) › Select2 not working › Reply To: Select2 not working
Here is the whole code:
// Change Field into a select
$field['type'] = 'select';
$field['ui'] = 1;
$field['ajax'] = 1;
$field['choices'] = array();
// get sites
$sites = $this->acf_get_sites();
// set choices
if( !empty($sites) ) {
foreach( $sites as $site ) {
//get blog name
$current_blog_details = get_blog_details( array( 'blog_id' => $site['blog_id'] ) );
// append to choices
$field['choices'][ $site["blog_id"] ] = $current_blog_details->blogname;
}
}
// render
acf_render_field( $field );
Its almost the same like the post_object. I have no JS errors. Without ui and ajax its just fine.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.