Support

Account

Home Forums Bug Reports get_field() resets $post? Reply To: get_field() resets $post?

  • I just did a quick test. I don’t have the same post types you have I just used posts. This is on a site that only has ACF active. The same post is output before and after using get_field(), so I’m not seeing anything in ACF.

    Unless it has to do with the specific field you’re getting. What type of field is 'mod'?

    
    $args = array(
    	'post_type' 	=> 'post',
    	'order'		=> 'ASC'
    );
    
    $items = get_posts( $args );
    foreach( $items as $post ) {
    	setup_postdata($post);
    	echo 'BEFORE<pre>'; print_r($post); echo '</pre>';
    	$field = get_field('test_field');
    	echo 'AFTER<pre>'; print_r($post); echo '</pre>';
    }