Skip Navigation

[Closed] query filters – DATES

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Christian Cox 3 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1863333
Screenshot 2020-12-02 at 10.15.38.png

Tell us what you are trying to do?
Hi I'm trying to creat a fair calendar with toolset. I got over 6000 posts and now I wanted to do the archive. Everything worked fine except for the query filter. The Start and End Date of the fair are in two customefields now I like to display just fairs that are today or upcoming and ordered by the start date, but it doesn't work.

Looking forward to your help

#1863657

Hi, date filters are a bit confusing because Toolset's custom date fields are stored in the database as Unix timestamp values. These values should be compared as UNSIGNED or NUMBER values. Please edit the date field Query Filters and try "ist ein/e UNSIGNED" instead of "ist ein/e DATE" in each data type option. Let me know if you see the expected results after adjusting the data types.

#1864345
Screenshot 2020-12-03 at 09.09.05.png

Hi Christian,

thanks for your tip. On one page the fair calendar is displayed perfectly but on another page I'm having an issue. I said order by start_date, then it shows "the view will display only posts that have a value for that field", but it actually shows only the fairs with no start_date... (see screenshot)

#1864445

Hi Christian,

the filter on the archive page works great.
I created a second page, built in Gutenberg with a toolset view with search, here the filter is not working. Total identical settings...
hidden link

Thanks for your help

#1864727

May I log in and see how this View is set up in the Block Editor? I'll be able to check and give you some feedback if you provide login credentials in the private reply fields here in the forum.

#1865045

I need the view to show only fairs with ts_date_end - now or later and with ts_location_city_name - "Berlin"
Okay so you want to remove front-end filters for end date and city name, and apply those filters automatically? Is that correct?

#1865819

Hi Christian,

I want to have the front-end filter for end-date and want to automatically apply the end-date and location_city_name filter 🙂

#1866801

Normally you will set date field filter "type of control" to "Datepicker" in the filter block configurations. That will allow your site visitors to select a date from a calendar, and prevent problems with different date formats. I've made this change for you. However, there is no simple way to prevent Users from selecting end dates before today, if that is what you mean.

It's a bit confusing, because normally when I see a start and end date filter I expect to see results that occur between those dates. If you configure the filter to show posts with end dates on or later than the selected date, events that end before the selected end date will not be displayed, which is confusing to me. Let me explain more with an example. Suppose an event started yesterday and ends tomorrow. When the page loads, this event will be displayed in results because the end date is after today. However, if the User selects the end date filter to be 3 days from today, the event will no longer appear because the end date is not after than the selected date. The end date is before the selected date. Normally I would expect to see events that occur between the selected dates, not events that end after the selected end date. Maybe I'm misunderstanding, but it seems like the end date filter should be configured to show results that have end dates on or before the selected filter date, with no option preselected.

To automatically set the City field, it is best to remove the front-end city filter from the custom search fields because there is no way to automatically select some option in the front-end select filter, other than to apply a URL parameter somehow to all the links that lead into this page. That means you would have to edit all the links coming into this page and apply a URL parameter, something like https://yoursite.com/page-with-view/?param=12345

Instead, you can add a City Field Query filter in the Query Filter panel, and specify the Berlin city option for this filter. This will automatically filter the View to show only those results matching the Berlin city, and will prevent Users from choosing another city in the front-end search filters. More info about Query Filters here: https://toolset.com/course-lesson/creating-a-view/#filter-the-list-of-posts

#1868607

Hi Christian,
sorry but I think we miss understand.

1) I want the output to show ONLY: fairs in Berlin and fair end-dates which are today or in the future. That´t my first priority!!

I will deactivate the front-end filter for now.

#1868895

Something strange was happening, and I'm not exactly sure what it was. I changed a few things in the View using the Block Editor, and the updates did not always appear on the front-end of the site. Sometimes the View results updated constantly, changing order randomly. Sometimes the search filters appeared even though they were disabled in the Block Editor. That is unusual. So I cleared the Kinsta Cloud site cache, deleted the View block and replaced it. Then I also made some changes in the Custom Search block, and now the results seem to be more accurate. All the results appear to have the city name field = "Berlin" and an end date on or after today. The results are ordered by start date. Can you check?

hidden link

#1869753

Hi Christian,

Berlin is working but I neet to adaped the view for 14 other sites (cities) and on the second page it´s not working again (hidden link). The view doesn´t show in the front end.
I cleared the Kinsta Cache and Borwser Cache.
Can you please tell me in detail what I should do.

#1869767
Screenshot 2020-12-09 at 09.42.35.png

Hi Christian,

now another error occured (see screan shot).

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/toolset-plugin-cannot-connect-to-toolset-com-3/

#1869839

Hi Christian,

now the view shows in the front-end but to do that, I need to exit the page, then enter the page again > then it shows "view can´t be found" and if I insert the view again it works... that can´t be normal or?

#1870321

Berlin is working but I neet to adaped the view for 14 other sites (cities) and on the second page it's not working again
Okay so you need a way to adjust the View so that the filter setting is different on each page. There are several options here, but not one simple solution.

1. You could change the Query Filter in this View to respond to a URL parameter, which would filter by a different city on every page. But that means you would also need to adjust the links to all these pages to include a URL parameter, like this:
https://yoursite.com/messen-in-berlin-2/?city=Berlin
https://yoursite.com/messen-in-essen/?city=Essen
https://yoursite.com/messen-in-leipzig/?city=Leipzig
I can give you more information about this if you'd like to use this approach, but most people don't like using URL parameters like this on every page.

2. You can create separate Views for each city page, and modify the Query Filters for each View to filter by the appropriate city. This approach would require more work in wp-admin, since you must create separate Views for each city page and modify them each independently. You could create something called a "reusable block" in the View's loop, which would allow you to reuse the design inside the loop for all Views. I can give you more information about that if you want to use this approach.

3. You can implement a custom code snippet that adjusts the filter settings for each page programmatically. We offer the Views Filter API wpv_filter_query that allows for customizing the filter settings with PHP. This would allow you to reuse the same View on all city pages.

4. If you're familiar with legacy Views shortcodes, you can configure this View's Query Filter to respond to a shortcode attribute, and insert the View in each page using the wpv-view shortcode, like so:

[wpv-view name="your-view-slug" city="Berlin"]

...or...

[wpv-view name="your-view-slug" city="Essen"]

...or...

[wpv-view name="your-view-slug" city="Leipzig"]

...and so on. This will allow you to reuse the same View on all city pages, but it also means you cannot edit the View directly in the Block Editor for each city page.

now another error occured (see screan shot).
This looks like a separate issue, so I've created a new ticket where we can discuss in more detail. It could be a temporary server issue, or it could be a problem where the automatic update process is not able to contact our site to get update information. In either case, the plugins should continue to work as expected but you may not receive update notifications. Let's follow up in the other ticket please: https://toolset.com/forums/topic/toolset-plugin-cannot-connect-to-toolset-com-3/

now the view shows in the front-end but to do that, I need to exit the page, then enter the page again > then it shows "view can´t be found" and if I insert the view again it works... that can´t be normal or?
That doesn't sound normal. Let's address the previous question first, then I can take a look at this again.

The topic ‘[Closed] query filters – DATES’ is closed to new replies.