Hi Community, has anyone come across a problem where a dynamic date ( {current_date:Ymd} ) in a meta query is passed literally to the database and is not translated into ‘20240403’ on April 3rd?
If I enter ‘20240403’ as the meta value then the query works fine, but with dynamic data the meta query has no effect.
The page is an archive page for a custom post type ‘activities’ and the subquery should make sure that all activities with a date in the past are not listed…
I used the Query Monitor plugin to look at the actual SQL that is executed and there I noticed that the dates of items are being compared to ‘{current_date:Ymd}’ instead of (for instance) ‘20240403’. That explains how it doesn’t work. Now I need to find out why and how to solve the problem.
The query is executed via FacetWP, as I need that functionality for proximity filtering of activity items.
Any ideas are welcome! Thanks!
Hi Bart,
Thanks so much for your report!
I’m not sure if the problem is related to FacetWP, but first, please change the Meta Query Type to “Datetime” and remove the “or” relation, which is superfluous as far as I can see.
If it still does not work, please test the same query without FacetWP. If it then works, it seems to be a FacetWP problem.
Best regards,
timmse
Hi timmse,
Thank you for replying.
The problem seems to be occurring on archive pages only. When I copy the exact same filter and grid elements to a normal page, than everything works fine.
Also, when I switch off the ‘is main query (search / archive)’-switch, the date subquery works, but then the FacetWP filters don’t.
It’s when merging needs to take place of the archive query generated by Wordpress and the extra parameters added by Bricks, and that whole ‘bundle’ is handed off to FacetWP for query execution, that this problem of the ‘unresolved’ dynamic date occurs.
Bricks has an integration with FacetWP. Could it be that in that integration query information is passed to FacetWP before dynamic data is resolved? At least in situations where a Wordpress archive query is also going on?
I’m happy to take this problem to FacetWP, but the unresolved dynamic date ({current_date:Ymd}) is in ‘Bricks’ format so I’m afraid they’ll point me right back to Bricks.
Do you have a suggestion as to next steps to take? Thank you very much!
Kind regards,
Bart
Hey Bart,
We are currently working on a similar problem.
Could you send temporary login credentials and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase so we can test a potential fix?
For others that have this problem and find this thread: Bricks support added some lines of code to my installation of the Bricks theme. It was experimental, but it did the trick! On archive pages, subqueries with dynamic date arguments now work beautifully. Thanks, Bricks support! They were unable to give assurance that the fix will be in the next release, as the code hadn’t yet gone through the review process. I’ll update a copy of the site first, when a new version of Bricks is released.
Hi Bart,
We’ve fixed this issue in Bricks 1.9.8 beta, now available as a manual download in your account (see changelog).
Please let us know if you are still experiencing issues.
As with any beta release, please do not use it on a production or live website. It is only meant for testing in a local or staging environment.