I am trying to filter a view to only show results (event posts) based on the current day of the week. I don't want to have to build a custom shortcode for this if I don't absolutely have too, as my site file access is limited.
Is there a way to use the Types date filter of TODAY() or DATE() to load just the day? For example to do something like TODAY(l) to pull the current day of the week?
You want to filter your view by the current day. Meaning you only want posts that have their custom field set to a date like today to be displayed in the view ?
Secondly you want to display what day it is on you view ?
I want to show event posts that are assigned to the same day in the week as the current date's day of the week. There are events that are checked to happen recurring on Mondays and Wednesdays and other events that recur on Tuesdays and Thursdays for example.
I have a custom field "Days of the Week" which lists all the days of the week, and I can tag which days of the week the event recurs.
I want to filter these events by the current day of the week...meaning... if day_of_week_custom_field = TODAY (day of the week) or if Monday = Monday. TODAY() being today's date, but only capturing the actual day of the week the PHP "l".
You Days of the week field isn't a Date field but rather a custom field that list out the days. In a case like this you won't be able to use this view filter as its the function returns a timestamp.
You will need to use this custom shortcode below to get today's date
Add this shortcode to the custom code section in Toolset -> Settings -> Custom Code. From there just activate it.
The shortcode is used like [wp_today_day]
So for your date filter you will need to set the filter to be filtered by a shortcode attribute. See Screenshot
Once you've done that the next thing you need to do is to register the shortcode so that it can be used as a view attribute. Go to Toolset->Settings->Frontend then scroll to 3rd party shortcode arguments and register the shortcode name there.
Finally just call your view with the field and the shortcode.
[wpv-view name='[wp_today_day]']
Hi Shane,
Sorry I didn't respond for a while to your final post on this support request. Thank you so much for your help. The custom shortcode worked well. I called the shortcode in the end with the following [wpv-view name="my-view-name" myattribute="[wp_today_day]"].