I'm writing a simple tab navigation and I'm facing this issue:
The function print_office works only when I'm inside a foreach.
//Doesn't work
print_office($loop->posts[0], true);
//Works
foreach ($loop->posts as $index => $post) {
print_office($post, true);
}
The print_office function makes use of Advanced Custom Fields' get_field('field_name').
EDIT:
I've put a var_dump($office) inside print_office.
When called outside the foreach I get:
object(WP_Post)#317 (24) {
["ID"]=> int(7)
["post_author"]=> string(1) "1"
[.....] //More fields;
}
When called inside the foreachI get:
FOREACH:object(WP_Post)#317 (24) {
["ID"]=> int(7)
["post_author"]=> string(1) "1"
[.....] //More fields;
}
So the only difference is that: FOREACH:object instead of just object.