Home › Forums › General Issues › If get_fields is empty not working › Reply To: If get_fields is empty not working
I Tried to change the last query with this one
<?php
// An array of arguments
$args = array(
'post_status' => 'publish',
'post_type' => 'show-item',
'posts_per_page' => $params['number_of_items'],
'orderby' => $params['orderby'],
'order' => $params['order'],
'meta_query' => array( // WordPress has all the results, now, return only the events after today's date
array(
'key' => 'date_de_debut', // Check the start date field
'value' => date("Y-m-d"), // Set today's date (note the similar format)
'compare' => '>=', // Return the ones greater than today's date
'type' => 'DATE' // Let WordPress know we're working with date
)
),
);
$field = get_field('date_de_debut');
if (!empty ($field)) {
$args['meta_key'] = 'date_de_debut';
$args['orderby'] = 'meta_value';
}
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) : $the_query->the_post();
$single_params = array();
$single_params['title_tag'] = $title_tag;
$single_params['show_single_layout'] = $show_single_layout;
$single_params['show_id'] = get_the_ID();
$single_params['article_classes'] = $this_object->getArticleClasses( $params );
$single_params['show_category'] = $show_category;
$single_params['show_date_range'] = $show_date_range;
$single_params['image_proportions'] = $image_proportions;
echo musea_elated_execute_shortcode('eltdf_show_single', $single_params);
endwhile;
} else {
esc_html_e( 'Sorry, no posts matched your criteria.', 'musea-shows' );
}
/* Restore original Post Data */
wp_reset_postdata();
?>
Butsame problem. Any idea?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.