I have a checkbox custom field for the 7 days of the week. In my view I'd like to output other custom fields from that CPT if today's day of week is one of those checkboxes chosen for that post. So for example if the post has Monday, Tuesday, Wednesday checked, and if today is Wednesday the content in the conditional will show.
I've already created a shortcode to output the name of today's day of the week ([day-of-week]). And I've tried:
I also tried [wpv-conditional if="( $(wpcf-happy-hour-days) eq '[day-of-week]' )"]
These did not work, but in the 2nd option if I replaced [day-of-week] with Monday it did work. If I replaced [day-of-week] with any other day it did not. So I'm guessing it's just looking at the first option in this checkboxes field which is Monday and not checking against the other days.
Important:
- As you are using custom shortcode inside [wpv-conditional] shortcode, you need to register your custom shortcode at:
=> Toolset => Settings => Front-end content tab => Third-party shortcode arguments
Thanks Minesh. And yes I had registered the shortcode [day-of-week] in the Toolset Settings. The shortcode appears to be working fine. The issue appears to be that when the conditional compares wpcf-happy-hour-days to the [day-of-week] it is only checking the first checkbox option which is Monday.
As you can see here it works today, which is Monday:
hidden link
But tomorrow there will be no content on the page. Your idea above would work but it will require 7 times the length of code, so 7 times the updating needed when I make changes. I'd really prefer not to use that if possible.
Well - I agree that you need to add [wpv-conditional] shortcode 7 times (one conditional statement for one day), but it should need to add one time only.
As you said tomorrow, will be Tuesday, so you would like to display listings belongs to Tuesday - correct? If yes, the code will work as it will display the content for Tuesday only. Did I misunderstand your requirement here?