Support

Account

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