Plugin crashes when get_fields is called in loop
-
I’m using get_fields in a loop like this:
foreach($frontpage_posts as $post) : ?> <?php // do foo here $timetoshow = ''; if($cat[0]->slug === 'some_slug') { $acf = get_fields($post->ID); $timetoshow = $acf['my_field']; } else { $timetoshow = date('d.m.Y', strtotime($post->post_date)); } ?> <!-- html output here... --> <?php endforeach; ?>
When doing that, it crashes with the following error:
Fatal error: Uncaught Error: Call to a member function init() on array in /my/host/wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php:209
Stack trace:
#0 /my/host/wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(310): acf_init()
#1 /my/host/wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(269): get_field_objects(85, true)
#2 /my/host/wp-content/themes/fwrhs/index.php(77): get_fields(85)
#3 /my/host/wp-includes/template-loader.php(106): include(‘/var/www/vhosts…’)
#4 /my/host/wp-blog-header.php(19): require_once(‘/var/www/vhosts…’)
#5 /var/ww in /my/host/wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php on line 209The post looks just fine to me, any ideas what might cause this?
- The topic ‘Plugin crashes when get_fields is called in loop’ is closed to new replies.