Support

Account

Home Forums ACF PRO 5.5.8 Update

Solving

5.5.8 Update

  • Just updated to 5.5.8 and ran into an issue where the ‘post_object’ type has stopped working correctly

    Rolled back and everything is back to normal. Not much other information other than this at the moment but investigating. It appears to be an iteration issue.

  • My field definitions:

    
    register_field_group(array (
    	'id' => 'acf_page-extensions',
    	'title' => 'Page Extensions',
    	'fields' => array (
    		array (
    			'key' => 'field_5800d28886448',
    			'label' => 'Block links',
    			'name' => 'block_links',
    			'type' => 'post_object',
    			'instructions' => 'Select pages to display in link blocks.',
    			'post_type' => array (
    				0 => 'post',
    				1 => 'page',
    			),
    			'taxonomy' => array (
    				0 => 'all',
    			),
    			'allow_null' => 0,
    			'multiple' => 1,
    		),
    		array (
    			'key' => 'field_5805e3f350cf1',
    			'label' => 'Latest Offers',
    			'name' => 'latest_offers',
    			'type' => 'post_object',
    			'instructions' => 'Select the pages you wish to link to as special offers.',
    			'post_type' => array (
    				0 => 'page',
    			),
    			'taxonomy' => array (
    				0 => 'all',
    			),
    			'allow_null' => 0,
    			'multiple' => 1,
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'page',
    				'order_no' => 0,
    				'group_no' => 0,
    			),
    		),
    	),
    	'options' => array (
    		'position' => 'normal',
    		'layout' => 'default',
    		'hide_on_screen' => array (
    		),
    	),
    	'menu_order' => 0,
    ));
    

    My display code:

    
    $blocks 		= get_field( "block_links" );
    
    foreach ($blocks as $blockPost) {
    
    	setup_postdata( $blockPost );
    
    	$blockTitle = get_field( "block_title", $blockPost->ID );
    	if(empty(trim($blockTitle))) {
    		$blockTitle = $blockPost->post_title;
    	}
    
    ?>
    
    <div class="small-12 medium-6 columns post-block">
    	<div class="img">
    		<h4><a>ID); ?>" class="hvr-sweep-to-right"><?php echo $blockTitle; ?></a></h4>
    	</div>
    </div>
    
    <?php
    	$count++;
    }
    
    wp_reset_postdata();
    
    ?>
    
  • Where it’s not working, is there any difference in what in what the field is returning before and after the update?

    
    $blocks 		= get_field( "block_links" );
    echo '<pre>'; print_r($blocks'); echo '</pre>';
    
  • After the update, all the custom fields are not returned. The loop iterates correctly but the values are not included ($blockTitle in my code).

    On checking the post where the fields value are entered, the custom fields are no longer being displayed.

  • I’m seeing a similar issue where the return_type => "object" setting is not working. all of my relationship settings and queries are returning the ID only, and not the object.

    i’ve submitted a bug report. hope this gets fixed soon.

    i’m rolling back to 5.5.7

  • I have a site that makes heavy use of post object fields and I’m not seeing an issue.

    Have you tried to see if this has anything to do with another plugin of something in the theme?


    @derickbailey
    when fields that should be returning objects start returning only IDs a lot of times it’s a filter, and a lot of those times it’s a pre_get_posts filter. Not saying that this is the case, but it’s something to check.

  • I have a similar problem with repeater. With 5.5.7 works just fine… after upgrading to 5.5.8 not.

  • If you’ve eliminated plugin and theme compatibility problems then you should submit a new support ticket https://support.advancedcustomfields.com/new-ticket/

  • Made some progress on this, using setup_postdata( $post_object ) is a no-no according to the codex. You should always use setup_postdata( $post ) where the var name is “$post” and not anything else.

    See Function Reference/setup postdata

    Switching my example from $blockPost to $post has partially cured the issue although it persists on “Trying to get property of non-object” on the last iteration.

  • Scratch that, on closer inspection, the get_field( ‘block_links’ ) isn’t returning a post object but rather a post ID.

    So, my field definition

    
    	register_field_group(array (
    		'id' => 'acf_page-extensions',
    		'title' => 'Page Extensions',
    		'fields' => array (
    			array (
    				'key' => 'field_5800d28886448',
    				'label' => 'Block links',
    				'name' => 'block_links',
    				'type' => 'post_object',
    				'instructions' => 'Select pages to display in link blocks.',
    				'post_type' => array (
    					0 => 'post',
    					1 => 'page',
    				),
    				'taxonomy' => array (
    					0 => 'all',
    				),
    				'allow_null' => 0,
    				'multiple' => 1,
    			),
    		),
    		'location' => array (
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'page',
    					'order_no' => 0,
    					'group_no' => 0,
    				),
    			),
    		),
    		'options' => array (
    			'position' => 'normal',
    			'layout' => 'default',
    			'hide_on_screen' => array (
    			),
    		),
    		'menu_order' => 0,
    	));
    

    The retrieval code

    
    $blocks = get_field( "block_links" );
    

    Is returning a post ID rather than the post object.

  • I would definitely start by looking for filters that alter queries, plugin or theme compatibility. Like I said, when something that’s supposed to return an object/array is instead returning ID values 99% of the time it has always been a pre_get_posts filter causing the issue, altering queries it should not be.

  • Also had to roll back to 5.5.7
    PHP-defined fields ceased to even show up on CPT edit screen with 5.5.8. Didn’t get any further than that, just figured I’d “chime in” here

  • Solved in 5.5.9 update.

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘5.5.8 Update’ is closed to new replies.