Ordenar loop por dos o más ACF
add_action( 'pre_get_posts', 'sortbyACFpre_get_posts' );
function sortbyACFpre_get_posts($query) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if (!is_admin() && $query->is_main_query()){
if ( is_home() ){
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'fecha_inicio',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'fecha_inicio',
// 'value' => date("Ymd", time()),
'compare' => 'EXISTS',
),
));
$query->set('orderby', array(
'meta_value_num' => 'DESC',
'date' => 'DESC',
));
}
}