Wordpress - ACF $array->ID没有带来任何东西


Wordpress - ACF $array->ID not bringing anything?

我使用高级自定义字段,并且我在中继器中有一个"关系字段",管理员可以在其中选择用户。

这段代码成功地带来了数组,但我不明白为什么$idinverx = $inverx->ID;不能工作。

我知道这可能是很基本的,但我以前做过很多次,我不知道为什么它不工作,有人能帮我吗?这是我的代码:

wp_reset_query();
$args2 = array(
    'post_type' => 'inversion',
);
$the_query2 = new WP_Query( $args2 );
if ( have_posts() ) : 
    while ( $the_query2->have_posts() ) : $the_query2->the_post(); 
        if( have_rows('comisiones') ):
            while ( have_rows('comisiones') ) : the_row();
            {
                $inverx = get_sub_field('inversionista_que_recibe_comision_de_esta_inversion');
                print_r($inverx); // I get an array displayed here
                $idinverx = $inverx->ID;
                echo $idinverx; // Nothing gets displayed... why? :(
            }
?> 
<?php
            endwhile;
        else:
        // no rows found
        endif;
?>
<?php endwhile; else: ?>
    <p>No hay Inversiones</p>
<?php endif; ?>

这是$inverx的内部:

Array ( 
    [ID] => 3 
    [user_firstname] => roberto 
    [user_lastname] => lozano 
    [nickname] => roberto 
    [user_nicename] => roberto 
    [display_name] => roberto lozano 
    [user_email] => roberto123@hotmail.com 
    [user_url] => http://roberto.com 
    [user_registered] => 2014-06-23 18:17:56 
    [user_description] => 
    [user_avatar] =>  
)

$idinverx是一个数组,所以你不应该把它当作一个对象。而不是使用:

$idinverx = $inverx->ID

应该使用:

$idinverx = $inverx['ID'];