Home › Forums › Backend Issues (wp-admin) › "get_field"/"get_fields" but with keys instead of names › Reply To: "get_field"/"get_fields" but with keys instead of names
I managed to temporarily solve it by doing this:
$field_name = get_field_object($field['acf_mirror_field'])['name'];
$field_object = get_field_object($field_name, 'option');
$values = get_field($field_name, 'option');
if( have_rows($field_name) ){
echo " this is a repeater";
while( have_rows($field_name) ) { the_row();
foreach($field_object['value'] as $sub_key => $sub_field){
foreach($sub_field as $repeater_key => $repeater_item) {
$subkey_object = get_sub_field_object($repeater_key);
var_dump($subkey_object['key']);
$field_object['value'][$sub_key][$subkey_object['key']] = $field_object['value'][$sub_key][$repeater_key];
// unset($field_object['value'][$sub_key][$repeater_key]);
}
}
}
}
Result:
array(4) {
[0]=>
array(4) {
["icon"]=>
string(6) "ico-01"
["txt"]=>
string(37) "22"
["field_5c8f423a718f0"]=>
string(6) "ico-01"
["field_5c8f43e5076f7"]=>
string(37) "22"
}
[1]=>
array(4) {
["icon"]=>
string(6) "ico-02"
["txt"]=>
string(42) "22"
["field_5c8f423a718f0"]=>
string(6) "ico-02"
["field_5c8f43e5076f7"]=>
string(42) "22"
}
[2]=>
array(4) {
["icon"]=>
string(6) "ico-03"
["txt"]=>
string(31) "22"
["field_5c8f423a718f0"]=>
string(6) "ico-03"
["field_5c8f43e5076f7"]=>
string(31) "22"
}
[3]=>
array(4) {
["icon"]=>
string(6) "ico-04"
["txt"]=>
string(44) "22"
["field_5c8f423a718f0"]=>
string(6) "ico-04"
["field_5c8f43e5076f7"]=>
string(44) "22"
}
}
But it’s very ugly and won’t run for every field type.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.