I have tried that and a few other things and couldn’t find anything obvious checking through your documentation (which is great btw, thanks for the effort). Been playing about with this for a few days now and think that the problem is with storing the value in a variable which has caused the same issue in a seperate script now.
Other than that small issue with that function though the plugin has been great, saved me a lot of time :).
Many thanks.
Got it working by not using the_sub_field.. either way I would like to get to the bottom of this for future use. Many thanks.
Working script:
// Stage two
// For each field id store each fitters name in the posts array in a new array named $values.
foreach($fields_id as $fields){
$rows = get_field('fitters', $fields);
if($rows):
foreach($rows as $row) {
$values[] = $row['fittersname'];
}
endif;
}
Below is a print out of post meta for first post id looped in “Stage 2” noted above.
ARRAY[26] = array (
'_edit_last' =>
array (
0 => '1',
),
'_edit_lock' =>
array (
0 => '1377120757:1',
),
'U_S_C_users' =>
array (
0 => 'a:1:{i:0;s:1:"2";}',
),
'U_S_C_message' =>
array (
0 => '',
),
'address' =>
array (
0 => 'Hotel',
),
'_address' =>
array (
0 => 'field_51dd2a41842f7',
),
'city' =>
array (
0 => 'Manchester',
),
'_city' =>
array (
0 => 'field_51dd2b96938b1',
),
'post_code' =>
array (
0 => 'M1 4PS',
),
'_post_code' =>
array (
0 => 'field_51dd2ba1938b2',
),
'country' =>
array (
0 => 'UK',
),
'_country' =>
array (
0 => 'field_51dd2bb6938b3',
),
'fitters_0_fittersname' =>
array (
0 => 'Rob',
),
'_fitters_0_fittersname' =>
array (
0 => 'field_520e07d86bcd7',
),
'fitters_0_fittersdayrate' =>
array (
0 => '90',
),
'_fitters_0_fittersdayrate' =>
array (
0 => 'field_520e08306bcd8',
),
'fitters_1_fittersname' =>
array (
0 => 'Ben',
),
'_fitters_1_fittersname' =>
array (
0 => 'field_520e07d86bcd7',
),
'fitters_1_fittersdayrate' =>
array (
0 => '80',
),
'_fitters_1_fittersdayrate' =>
array (
0 => 'field_520e08306bcd8',
),
'fitters_2_fittersname' =>
array (
0 => 'Phil',
),
'_fitters_2_fittersname' =>
array (
0 => 'field_520e07d86bcd7',
),
'fitters_2_fittersdayrate' =>
array (
0 => '90',
),
'_fitters_2_fittersdayrate' =>
array (
0 => 'field_520e08306bcd8',
),
'fitters' =>
array (
0 => '3',
),
'_fitters' =>
array (
0 => 'field_520e07c46bcd6',
),
);
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.