I answer myself :
$posts = get_posts(array(
'post_type' => 'club_type',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'comite_associe',
'value' => '"' . $IDcomite . '"',
'compare' => 'LIKE'
)
)
));
Thank you very much for your leads, I found a solution that seems to work well :
add_option('ebo_dernier_num_club','3005','','no');
function ebo_renseigne_num_affiliation($value, $post_id, $field) {
if (! $value && get_post_type($post_id)=='club_type') {
$last_num = (int) get_option('ebo_dernier_num_club', '3000');
$last_num++;
update_option('ebo_dernier_num_club', $last_num);
$value = $last_num;
}
return $value;
}
add_filter('acf/update_value/name=numero_affiliation', 'ebo_renseigne_num_affiliation', 10, 3);
I also wanted to make the field uneditable with this function:
function msk_acf_disable_field($field) {
$field['disabled'] = true;
return $field;
}
add_filter('acf/load_field/name=numero_affiliation', 'msk_acf_disable_field');
But that does not seem to be compatible.
Maybe a little help ?
Thank you in advance!
It’s perfect.
Thank you very much for your help!