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
meta_query needs to be a nested array
either
'meta_query' => array(
array(
'key' => 'program_id',
'value' => '5317',
'compare' => 'LIKE'
)
),
or
'meta_query' => [
[
'key' => 'program_id',
'value' => '5317',
'compare' => 'LIKE'
]
],
@trisham the second way is a shorthand that was added in PHP 5.4, similar to how arrays can be declared in JavaScript, which I prefer not to use. Mostly because my IDE does not understand it and shows a syntax error that prevents me from seeing real syntax errors. Besides, it only saves typing out “array” which I do instinctively and would save me what? Less than a second? I also find it a lot less clear when reviewing code.
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.