• The relationship field, now that you changed it to make the post IDs to save as strings, saves an empty relationship field as an array with a single index that is an empty string. it breaks get_post_meta queries and empty checks against post_meta.

    I know why you did the changes to the way it stores relationship values but it ends up creating these: a:1:{i:0;s:0:"";} for empty fields.

    I was able to jurry-rig this issue in class acf_field_relationship as follows:

    function update_value( $value, $post_id, $field ){
    		if(!empty($value)){
    			if( is_string($value) ){
    				$value = explode(',', $value);
    			}elseif( is_object($value) && isset($value->ID) ){
    				$value = array( $value->ID );
    			}elseif( is_array($value) ){
    				foreach( $value as $k => $v ){
    					if( is_object($v) && isset($v->ID) ){
    						$value[ $k ] = $v->ID;
    					}
    				}
    			}else{
    				return $value;
    			}
    			$value = array_map('strval', $value);
    		}
    		return $value;
    	}

    https://www.ads-software.com/plugins/advanced-custom-fields/

  • The topic ‘Relationship Field Broke’ is closed to new replies.