簡體   English   中英

WordPress MU中的ACF重發器字段(位於“選項”頁面上)不返回數據

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

我似乎在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 );
}

如注釋中所述,正常字段起作用,但是當我嘗試從轉發器字段檢索數據時,它只是空的。

我認為您需要用於多站點環境的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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM