Loop filtering for empty ACF fields?

I have just started out testing L&L and wondered if somebody could help with how to handle empty ACF fields?

The template code below works but if I save a new post that does not have a mycustom_acf_date_field value ACF stills saves an empty entry into post meta table. So now the Loop also include the post with empty mycustom_acf_date_field value which it should not.

<Loop type=mycustom post type custom_field=mycustom_acf_date_field orderby_field_number=mycustom_acf_date_field  sort_order=desc count=5 >
   <Field title /><br />
</Loop>

Interesting, I guess that makes sense. Does adding these two parameters work for you?

<Loop type=my_cpt custom_field=my_date_field custom_field_compare=not custom_field_value="">

Yes that works. Thanks. Too bad there is no easy way to stop ACF from saving empty fields to post meta.

1 Like