Support

Account

Home Forums General Issues If get_fields is empty not working Reply To: If get_fields is empty not working

  • They all have a value, this snippet replace the existing value

    if (get_field(‘date_de_debut’)) {
    $query_array[‘meta_key’] = ‘date_de_debut’;
    $query_array[‘orderby’] = ‘meta_value’;
    }

    I think this has to be with the post ID. But why is it working if I use this:
    $query_array = array(
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘show-item’,
    ‘posts_per_page’ => $params[‘number_of_items’],
    ‘orderby’ => ‘meta_value’,
    ‘meta_key’ => ‘date_de_debut’,
    ‘order’ => $params[‘order’]
    );