Home › Forums › Front-end Issues › Select2 not pulling saved values on MultiSite › Reply To: Select2 not pulling saved values on MultiSite
I finally tracked down the issue and thought I’d post my findings. The hack option didn’t work. I’ll post the code I used and you can tell me if that’s what you were suggesting I try. So far as I can tell, the breakdown happens on line 643
of class-acf-field-taxonomy.php
in the render_field_select
function. $this->get_terms
doesn’t return any terms on subsites. It looks like i’ll have to pursue creating my own field that modifies the taxonomy field.
function switchBeforeRender( $field ) {
if ( ! Site::isRoot() ) {
$currentSite = get_current_blog_id();
switch_to_blog( Site::getRootBlogId() );
set_transient( 'switchBeforeRender', $currentSite );
}
}
add_action( 'acf/render_field/type=select', 'switchBeforeRender', 8, 1 );
function switchAfterRender( $field ) {
$originatingSite = get_transient( 'switchBeforeRender' );
$currentSite = get_current_blog_id();
if ( $currentSite === 1 && $originatingSite ) {
delete_transient( 'switchBeforeRender' );
switch_to_blog( $originatingSite );
}
}
add_action( 'acf/render_field/type=select', 'switchAfterRender', 15, 1 );
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.