Home › Forums › Front-end Issues › get all posts in custom post type by ACF field value › Reply To: get all posts in custom post type by ACF field value
@hube2 thank you for the explanation! I’m also so accustomed to typing ‘array’ that I don’t even think about it anymore….but it’s good to know the shortcut.
In the OP’s case, then it looks like his query is written correctly *except* that my understanding is that “LIKE” is for strings, but the meta_value looks like a number, so perhaps adding the meta_type and changing the operator to ‘=’ should work?
Like so:?
'meta_query' => [
'key' => 'program_id',
'value' => 5317,
'type' => 'numeric',
'compare' => '='
],
OR alternatively just do the query without using meta_query, like so:
$student_query_args = [
'post_type' => 'student_list',
'post_status' => 'publish',
'posts_per_page' => 100,
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_key' => 'program_id',
'meta_value' => '5317'
];
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.