Skip Navigation

[Résolu] Views Date filtering unexpected results

This support ticket is created Il y a 4 années et 10 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Marqué : ,

This topic contains 5 réponses, has 2 voix.

Last updated by Luo Yang Il y a 4 années et 10 mois.

Assisted by: Luo Yang.

Auteur
Publications
#1273049

I have a post type "Exhibitions" which has two date fields: "Exhibition Viewing Start" and "Exhibition Viewing End".

I have three views set up:

Exhibitions Past:
Select items with field: Exhibition Viewing End is a NUMBER lower than TODAY()

Exhibitions Now Showing:
Select items with field: Exhibition Viewing End is a NUMBER greater than or equal TODAY()
AND
Exhibition Viewing Start is a NUMBER lower than or equal TODAY()

Exhibitions Coming Soon:
Select items with field:
Exhibition Viewing Start is a NUMBER greater than TODAY()

If you take a look at this page: hidden link you'll note there are three shows that should be under "Now Showing" but are under "Coming Soon" - check the dates listed beside "Viewing:"

Have I made an error in my logic in setting these up? Any idea why this doesn't appear to be working correctly?

#1273109
Now-Showing.JPG

Hello,

I have tried the URL you mentioned above, but I can see only one item under"Coming Soon", which is June 29, see screenshot Now-Showing.JPG.

I assume your custom date fields "Exhibition Viewing Start" and "Exhibition Viewing End" are using option: Input date and time.

If it is, I suggest you change the filter of view "Exhibitions Now Showing" as below:

Select items with field: Exhibition Viewing End is a NUMBER greater than or equal NOW()
AND
Exhibition Viewing Start is a NUMBER lower than or equal NOW()

More help:
https://toolset.com/documentation/user-guides/date-filters/
NOW() (the time at the moment in milliseconds)

#1273129

No, they are just date fields- no time involved. Does that matter?

Yeah, sorry about that, the site is live and there's clearly some issue with it since there should be three shows under "Now showing" (compare what's listed there to what's on the homepage hidden link, they have the same filtering settings)

#1273223

It does not matter, you just need to setup the filter for views as I mentioned above:
1) "Exhibitions Now Showing"
Exhibition Viewing Start<= now() <= Exhibition Viewing End

2) "Exhibitions Coming Soon":
Exhibition Viewing Start >= now()

If the problem still persists, please try these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, deactivate all custom PHP/JS code snippets, and test again

2) please provide database dump file(ZIP file) of your website, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1273267

Thanks for the details, I am downloading the files, will update here if there is anything found

#1273271

Here are what I found, the post view "Exhibitions Now Showing" does work, it can output three items of today's date June 20 2019, but you are using a conditional shortcode in this view, and conducts the problem, please try these:
Edit the post view "Exhibitions Now Showing":
hidden link

In section "Loop Editor", add below line just after last [/wpv-conditional] tag, for example:

      [wpv-conditional if="( '[wpv-items-count]' >= 3 )"]
      	<div class="col-sm-4">
          [wpv-post-body view_template="loop-item-in-exhibitions-now-showing"]
        </div>
      [/wpv-conditional]

Your existed conditional shortcode can output results only when there are one or two results, above condition will be able to output results when there are three or more results.

More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
>= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.