Support

Account

Home Forums General Issues A point on Date fields in WP_Query Reply To: A point on Date fields in WP_Query

  • Hi Nox,

    Yes I sent you an answer, not visible here … Weird. I don’t know if you get me answer by email even if it isn’t visible here ? What matters is you get your solution =)

    For the first issue, yes you’re right, we can assume “ACF finally asigned an empty string (and not a null value) in the meta key” because as I try to tell in my “ghost answer” the ‘NOT EXISTS’ operator means the metadata isn’t set or is set to null. When you have this kind of issue the best way is to test your metadata this way (use it in single_post.php for exemple) :

    if( ! in_array( 'date_sale', get_post_custom_keys( $post_id ) ) ) {
        Echo ‘The metadata isn’t set, the NOT EXISTS operator must works’; 
    } else {
        $my_sale_date_meta = get_post_meta($post_id, ‘date_sale’);
        If(is_null($my_sale_date_meta)){
            Echo ‘The metadata is null, the NOT EXISTS operator must works’;
        } else {
            Echo ‘The metadata is set and not null, the NOT EXISTS operator can\’t work’;
        }
    }

    For your second issue, I assume your first arguments doesn’t works because your ‘date_sell‘ format isn’t comparable to the $date_limit format. If you have another issue like this, the best way to find an answer is to print your arguments using native WP or PHP function (not ACF one which may “traduce” the metadata depending on field settings).

    Have a good coding day !