Support

Account

Home Forums ACF PRO get_field('field')['subfield'] vs get_field('field_subfield') Reply To: get_field('field')['subfield'] vs get_field('field_subfield')

  • 
    get_field('field')['subfield'];
    

    calls

    
    get_field('field');
    

    so ACF gets the entire group field as an array

    
    get_field('field')['subfield'];
    

    is simply returning one element of that returned array. So yes, this could create extra work if you do not want to get the entire group and all of its sub fields.

    Basically what you are doing is a shortcut for

    
    $array = get_field('group_field');
    value = $array['sub_field'];