WAIT: JetEngine with query loop problems with date meta query

Sorry if I can’t express myself well, the problem is quite complex.
I have already invested many hours to find the error, but I have only been able to achieve partial solutions.

There is a CPT called Events (Program)
I will have 3 days with lots of programs / day, and want to make a separate list of each day’s program, in a nestable tab.

So I did everything with query loop, and wanted to list the exact date’s program in exact tab content. I used like a filter the meta query option in Bricks’s query loop.

If I’m using in JetEngine (date) meta timestamp function never use it! I can’t make any listing, it says every time the list is empty.

After I turned off the timestamp function, I can make listing great.

BUT!
If I made 3 listings (1. day program / 2. day programs / 3. day programs) It lists ALL 3 DAYs program all of 3 listings! :smiley:

I tried out the JetEngine own query builder. In jetengine preview mode I can see correctly the queries, but when I add it to Bricks query loop, same problem.

If I make ONLY one query listing with one day, its working good.

I made a long video where you can see the Default Bricks and JE query builder SAME error.

https://jam.dev/c/aa077173-0fa2-49ac-8355-2d7ce6c94fca

Hey @simplecreative,

thanks for your report.

It’s so hard to follow videos without an explanation though. It would be really awesome if you could explain what you’re doing and trying to achieve while showing it.

As already answered in your other thread the meta value you’re using does not make any sense. You either compare to the current date {current_date:Ymd} (or whatever format you need to match the db format) or to a specific date 20231107 (or whatever format you need to match the db format). {current_date:2023-11-07} is not a valid tag / filter combination and does not make any sense (see academy article).

Best,

André

1 Like

I hope I have understood correctly what you try to achieve. As @aslotta explained, your Meta-Value in the loop is NOT valid. If you want to query for: the current date, the day after the current date and the day after that day, I think you need a custom php-function. You could then make a php function like the following:

<?php 
function my_getDate($format, $daysToAdd) {
    // Get the current date
    $currentDate = new DateTime();
    
    // Add the specified number of days
    $currentDate->modify("+$daysToAdd days");
    
    // Format and return the date
    return $currentDate->format($format);
}
?>

You can add this function to your theme’s functions.php or you use a plugin like wpcodebox for example.

And then in your meta-query, inside of your meta-value field, call the following:

//for the second param: 0 = current_date, 1 = day after current date, 2 = 2 days after current date, and so on ....

{echo:my_getDate('Y-m-d', 0)}

Hope it helps! Br

Tobias

2 Likes

Hi Aslotta!

I found the problem. If I want to use the date meta with timestamp function, I cant use it like meta query.

The other glitch what i was written in top (query lists not separate) is very strange.
The glitch is between query loops and nestable tabs. I dont know how and when, but after I tried build it again about 5 times, one time it was working. :smiley: (Every options was SAME). So, now, I never touch again my Nestable tabs with query loops Section. :smiley:

Sorry, maybe my bad english the problem, but I dont unerstand clearly your answer.
I think the meta query is good, and was the problem is the timestamp function. I turned off and rebuild again my query. Here is the screenshot, you can see, it is working, what you said, it no.