简体   繁体   中英

ACF repeater fields (on and options page) within a Wordpress MU not returning data

I seem to have a problem retrieving ACF repeater fields (on and options page) within a Wordpress Multisite environment.

(the options pages are on the child sites)

This is my code below:

$bids = Array();
$blogs = wp_get_sites();

foreach ($blogs as $blog) {
    array_push($bids, $blog['blog_id']);
}

$original_blog_id = get_current_blog_id();

$k = 0;
foreach($bids as $bid) {
    switch_to_blog($bid);

    // this works
    $centre_facebook_link = get_field('centre_facebook_link','option')  

    // this doesnt
    if( have_rows('about_team','option') ) {
        while ( have_rows('about_team','option') ) { the_row();
            $person_image = get_sub_field('person_image');
            $person_full_name = get_sub_field('person_full_name');
            break;
        }
    }
    switch_to_blog( $original_blog_id );
}

As noted in the commenting the normal fields work, but the moment I try to retrieve data from the repeater field it just comes up empty.

I think you need ACF sync plugin for multisite environment.

https://wordpress.org/plugins/acf-multisite-sync/

if it doesn't help check : https://github.com/tmconnect/acf-relationship-multisite

another way to do it is :

switch_to_blog( $current_site );
$GLOBALS['_wp_switched_stack'] = array();
$GLOBALS['switched']           = FALSE;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM