Wordpress MU中的ACF转发器字段(打开和选项页面)不返回数据

时间:2016-02-02 08:13:16

标签: php wordpress advanced-custom-fields multisite

我似乎在Wordpress Multisite环境中检索ACF转发器字段(打开和选项页面)时遇到问题。

(选项页面位于子站点上)

这是我的代码:

$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 );
}

正如评论中所指出的那样,普通字段可以正常工作,但是当我尝试从转发器字段中检索数据时,它就会变空。

1 个答案:

答案 0 :(得分:0)

我认为您需要多站点环境的ACF同步插件。

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

如果没有帮助检查: https://github.com/tmconnect/acf-relationship-multisite

另一种方法是:

switch_to_blog( $current_site );
$GLOBALS['_wp_switched_stack'] = array();
$GLOBALS['switched']           = FALSE;
相关问题