Hey all,
I’m working on a front-end portion of the site where I need to display the field label and data. I’m successfully able to get the field and data, however, the label seems to be blank.
Here is what I’m doing:
First, I get the fields:
$user_meta = get_fields('user_'.$userid);
Then, I loop through each to get the ones I want. I’ve prefixed the ones I want with user_q_:
$questions = array();
foreach ($user_meta as $meta_name => $value):
if(strpos($meta_name, 'user_q_') !== FALSE):
$questions[$meta_name] = $value;
endif;
endforeach;
So far so good, however, then I try to display the question labels and value and the label is blank:
<?php foreach($questions as $question => $value):
$field = get_field_object($question, false, array('load_value' => false));
?>
<h3><?php echo $field['label']; ?></h3>
<div><?php echo $value; ?></div>
<?php endforeach; ?>
If I print out the $field object from above, here is the results for one of the values:
Array ( [key] => field_user_q_about [label] => [name] => user_q_about [type] => text [order_no] => 1 [instructions] => [required] => 0 [id] => acf-field-user_q_about [class] => text [conditional_logic] => Array ( [status] => 0 [allorany] => all [rules] => 0 ) [default_value] => [formatting] => html )
As you can see, the label value is blank.
Any thoughts, ideas, hints, things to look at? Am I doing something completely wrong?
Thanks for any advice!