Display a view with entries on a specific date using code

By: Naomi Spirit | Asked: 11/23/2023
ForumsCategory: How-toDisplay a view with entries on a specific date using code
Naomi SpiritNaomi Spirit asked 5 months ago
I want to use the view on several pages, each page would display entries from a different date.   I want to add it as code as opposed to the UI. How do I go about this? Is there an example somewhere of filtering the view programmatically?
Question Tags:
2 Answers
Best Answer
Naomi SpiritNaomi Spirit answered 5 months ago

Hi Victor In terms of our website, we want to have a page for each day, showing entries for that day, for the duration of our event.  It wouldn't be suitable to put within one page.  Thank you, your code hint  frm-set-get shortcode was just what I needed as I was off down the wrong rabbit hole. I have made a page template for each of these pages which shows both the entry form and the view for the event.  We want to view to be restricted to showing entries only for a specific date.

The following code does just that!   

$fromdate = getDateForPage() - 1; 
$todate = getDateForPage() + 1;
do_shortcode('[frm-set-get date_range_start="'.$fromdate.'" date_range_end="'.$todate .'"]');
('[display-frm-data id='.tw_get_view_ID().' ]');

 Combined with using a param name in the filter of the UI as in attached picture. [get_param=date_range_start] Happy days!

Victor Font answered 5 months ago
What do you mean by "as opposed to the UI"? Do you mean you don't want to use the view filter builder? You don't need multiple pages to display a view for different dates. You need one page that passes a date parameter to the view either with a query string or the frm-set-get shortcode. To do this, use the view filter by filtering the date with [get param = parameter]. If you want to something completely in PHP, then use the frm_view_order filter. You can rebuild the entire Formidable SQL query to your liking.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community