Home › Forums › General Issues › Meta query for image field issue › Reply To: Meta query for image field issue
Thanks again for keep supporting me here, particular as this is clearly a wp issue as I understand now.
Since I had to come up with a quick solution I just decided to go for the following workaround:
When I import a new image I set the value of the image field explicitly to ”. (Which is very doable in my case as I create all posts via wpcli …)
Since there is no need anymore to check for cases of non existent image fields I just query as follows (which is the complete query as i use it in my actual program, including only an additional paged parameter)
$wp_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 15,
'paged' => $paged,
'meta_key' => 'delight_image',
'meta_query' => array(
array(
'key' => 'delight_image',
'value' => '',
'compare' => '!=',
),
),
) );
Luckily it now works as expected. Sorry I didn’t dig deeper into this but sometimes workarounds are just the way to go 🙂
thanks
maritn
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.