Support

Account

Home Forums Add-ons Repeater Field get_field repeater not returning array Reply To: get_field repeater not returning array

  • This can also happen if you call get_field too early, I had a case where I called it at the top of the functions.php file in a $_GET check and it wouldn’t load the data for a repeater field, just the number of elements.
    For Example:

    
    if( $_GET['dostuff'] == 'yes'){
      $data = get_field('fieldname', 'option');
      //do stuff
      //$data returned "3"
    }

    I solved this by moving it to a function in an init action

    
    if( $_GET['dostuff'] == 'yes'){
    add_action('init', 'functionname');
    }
    function functionname(){
      $data = get_field('fieldname', 'option');
      //do stuff
      //$data returned array
    }