get all posts in custom post type by ACF field value
I have a custom post type with custom fields(advanced custom fields plugin). one of the custom fields named program_id. i can`t understand how to get all of the posts in that CPT where the ACF field value is x, and only them. i read ACF guide but i always get all of the post.
$student_query_args = [
'post_type' = 'student_list',
'post_status' = 'publish',
'posts_per_page' = 100,
'order' = 'DESC',
'meta_query' = [
'key' = 'program_id',
'value' = 5317,
],
];
$student_query = new WP_Query($student_query_args);
if ($student_query-have_posts()) {
while ($student_query-have_posts()) {
$student_query-the_post();
echo 'br' . the_title() . 'hr/';
}
}
Topic advanced-custom-fields Wordpress sql
Category Web