0

I have the following issue:

I run the following query:

$interventii = get_posts( array(
                    'post_status'       => 'publish',
                    'post_type'         => 'interventii',
                    'meta_query'        =>  array(
                        array(
                                'key'   =>  'interventie_data_interventie',
                                'value' =>  array($azi, $aziAltFormat),
                                'compare' => 'IN'
                        ),
                    ),
                    'posts_per_page'    => 9999999,
                    'order'             => 'DESC',
                    'orderby'           => 'date',
                ) );

On the same page I also have a select input where I choose a new date ($azi variable) which triggers an ajax call with a function that runs the get_posts() with the new $azi variable. The issue is that if the initial $interventii is empty and returns no posts for the default date ($azi) then even if I choose a new date and I know for sure that it has posts, it will return empty. If there are posts on the default date, then the functions and the ajax call runs without any issues even if I choose another date.

The interesting thing is that if the initial query has posts, the ajax works just fine. If the initial query returns no posts, then the ajax will return no posts as well even if I know for sure that based on the selected date, we have posts in the db

What could be the problem here?

Thanks!

9
  • Hard to tell from the outside, or based on just this snippet. I'd install a plugin like Query Monitor and check what database queries are actually getting executed. Commented Sep 11 at 7:28
  • The interesting thing is that if the initial query has posts, the ajax works just fine. If the initial query returns no posts, then the ajax will return no posts as well even if I know for sure that based on the selected date, we have posts in the db. Commented Sep 11 at 7:38
  • Please compare the date with the database date format. Commented Sep 19 at 7:41
  • 1
    @BhaviniShah $aziAltFormat is not stored in the DB, it is actually the $azi variable but with a different date format. $azi is stored in the DB as a static date. Commented Sep 26 at 7:29
  • 1
    @MortezaBarati maybe you are right, let me check if it works. Thanks! Commented Sep 30 at 10:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.