Support

Account

Home Forums Bug Reports get_field image returns ID only on search results page (PRO) Reply To: get_field image returns ID only on search results page (PRO)

  • 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
    }