NO BUG: Date comparison and conditions not working

Browser: Chrome 114
OS: macOS.
URL: Voor kinderen - Kunsthal Kade
Video: CleanShot 2023-07-17 at 13.58.15 · CleanShot Cloud

Hey there, I am using Bricks 1.8.3 and wish to create some conditional pages, but it is not working as I expected. I have been struggling with date conditions before, but I applied what I learned before. So, my issue:

I have a query loop with a post type (‘voor kinderen’). The query must only show the posts that have a date equal or later than the current date. Then, it must also be ordered by the date, with the post having the date nearest to the current date as first, then ascending.

I have set up the date metabox field with the ID of ‘kids_startdatum’. However, I also use a prefix for the group, which is ‘pagina_’. So, that would make the ID to use: ‘pagina_kids_startdatum’. This can also be found in the database.

I have set up the date format as ‘d.m.Y’, in metabox ánd WordPress. So, if I echo {current_date}, it displays it in that format. When I check the database, it shows the same format.

I also use the date comparison in the conditions to show specific headings. The condition is: CleanShot 2023-07-17 at 14.07.39 · CleanShot Cloud. This is set accordingly to the right headings. It does not work.

I run into a couple of issues:

  1. The query loop shows every post.
  2. The ordering is not working.
  3. The conditions are not working for the heading.

I did my own investigation already. I found out that for at least problems 2 and 3, the comparison is based upon the day, instead of the full date (day, month and year).

Hey Brian,

thanks for your report.

This is not a Bricks bug. Make sure to store the custom date values in the database in a format that allows for correctly sorting / querying them (like Ymd or Y-m-d).

From the Meta Box documentation:

However, this is the format that users see in the date picker. You might want to save the value in another format, like 2022-10-20 , which allows you to sort or query posts by date. To do that, set the value of “Save format” to Y-m-d . Unlike the above, the saved format is the PHP date format , which is similar to PHP’s date() function.



Hi Andre,

Thanks, I was also looking into this, but what I did not achieve was the output of ‘d.m.Y’ of the metabox date field if I save it differently. How could I achieve this with the Bricks query loop then?

Alright, it is not a bug, but just a pain in the… Anyway! I made a custom function in WPCodeBox and handwrite the html with php code in order to achieve the proper HTML structure and use the right output. Thanks for the time anyway!