After upgrade the plugin to the 4.3.8 version, now i have problems with the ‘get_field‘ funtion on all the Relationships Fields. It is returning always an empty array. Before that, i have no problems and it returned the object.
All is working ok in the backend and the data is stored in the BBDD
In the BBDD i got :
meta_id post_id meta_key meta_value
103585 7391 sendero_variante a:1:{i:0;s:4:"3938";}
103586 7391 _sendero_variante field_535952a60acb8
With :
$post_sendero = get_field("sendero_variante", 7391);
And :
$fields = get_field_objects();
if( $fields ) {
foreach( $fields as $field_name => $value ) {
$field = get_field_object($field_name, false, array('load_value' => false));
echo '<div>';
echo '<h3>' . $field_name . '</h3>';
echo '<pre>';
print_r($value);
echo '</pre>';
echo '</div>';
}
}
I got an empty array for ‘sendero_variante’ field.
The fact is that i only have problems when i used my custom post on the relationship, because if i instead use ‘pages’ it returns ok the object.
This is the field definition :
array (
'key' => 'field_535952a60acb8',
'label' => 'Sendero / Variante',
'name' => 'sendero_variante',
'type' => 'relationship',
'return_format' => 'object',
'post_type' => array (
0 => 'sendero',
),
'taxonomy' => array (
0 => 'all',
),
'filters' => array (
0 => 'search',
),
'result_elements' => array (
0 => 'post_title',
),
'max' => 1,
)
And this is my custom post :
$icon = version_compare(get_bloginfo('version'), '3.8', '>=') ? 'dashicons-chart-area' : false;
register_post_type('sendero', array(
'labels' => $labels,
'singular_label' => 'Sendero',
'public' => true,
'exclude_from_search' => true,
'show_ui' => true,
'menu_icon'=> $icon,
'capability_type' => 'sendero',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => true,
'menu_position' => 20,
'query_var' => true,
'show_in_nav_menus' => false,
'supports' => array('title', 'editor')
));
Thank you!