I've got exposed date filter (with daily granularity) and I want to provide default value for it. I just want to show nodes that have today 'field_date' date by default. The field has both start and end date. I use start date for exposed filter.

How can I achieve it?

This can be done through contextual filters in views.

Navigate to edit the structure of your view, click advanced and add a contextual filter. Here you will select the date field and "Apply"

On the next page, under "WHEN THE FILTER VALUE IS NOT IN THE URL" you want to "Provide default value" of type "PHP Code". The code you want to use is fairly simple, but depends on your date/time setup. you should have something like this in the php code field:

return date("Y/m/d"); 

Good Luck!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.