function
function list_formation(){
$args = array(,
'post_type' => 'categories',
'posts_per_page' => 20,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$formations = get_posts(array(
'post_type' => 'formations',
'post__in' => array(16061),
'meta_query' => array(
array(
'key' => 'categories', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
if($formations){
foreach ($formations as $categorie){
// $list = get_field('formations', $formation->ID);
// list of categorie with ID formation
echo the_title() . '</br>';
}
}
endwhile;
wp_reset_postdata();