If-statement based on custom field and day of the week

Hi all!

I’m trying to use Loops & Logic to show a ACF Repeater field based on the day of the week. There’s a checkbox field that returns a list with numbers of days of the week on which the program name inside the If-statement should be shown.

<Set current_day><Date format="N">now</Date></Set>

<Loop acf_repeater=programma from=options>
  <If list="{dagen_programma}" any_is value="{Get current_day}">
    <Field naam_programma />
  </If>
</Loop>

This is the output from the fields when I print them:

dagen_programma = ["1","2","3","4","5","6","7"] 
current_day = 1

I’ve tried ever combination in the If-statement, but I cannot get it to work. What am I doing wrong here? Could it be a string vs integer problem? (I’ve tried wrapping the current_day in quotation marks) Could it be that the {Get current_day} is wrong? Any help is much appreciated! :pray:

I fixed it!

I ended up removing the [] tags from the ACF output and wrapping the variable in quotation marks, which made the comparison work.

<Set days><Format trim="[]"><Field dagen_programma /></Format></Set>

and

<Set day>"<Date format="N">now</Date>"</Set>

I’m quite happy with this, but maybe there’s a better way?

Thanks :smiley:

2 Likes