Sorry, I put my code again on the proper way.
<?php
// filter
date_default_timezone_set(“Europe/Rome”);
$giorno2 = “Tuesday”;
// filter
function my_posts_where2( $where2 ) {
$where2 = str_replace(“meta_key = ‘programmazione_%”, “meta_key LIKE ‘programmazione_%”, $where2);
return $where2;
}
add_filter(‘posts_where’, ‘my_posts_where2’);
$args2 = array(
‘cat’ => ‘palinsesto’,
‘post_type’ => ‘post’,
‘meta_query’ => array(
‘key’ => ‘programmazione_%_giorni’,
‘compare’ => ‘LIKE’,
‘value’ => $giorno2,
),
‘order’ => ‘DESC’,
‘orderby’ => ‘meta_value’,
‘meta_key’ => ‘programmazione_%_orainizio’,
‘meta_type’ => ‘TIME’
);
// query
$the_query2 = new WP_Query( $args2 );
?>
<?php if( $the_query2->have_posts() ): ?>
<?php while( $the_query2->have_posts() ) : $the_query2->the_post(); ?>
<div class=”primo”>
<div class=”info”>
<span class=”titolo”>“><?php the_title(); ?></span><br/>
<?php
$html = ”;
ob_start();
if(have_rows(‘programmazione’)):
while(have_rows(‘programmazione’)): the_row();
if (strpos(get_sub_field(‘giorni’),$giorno2) !== false):
the_sub_field(‘orainizio’); echo ‘ – ‘; the_sub_field(‘orafine’);
endif;
endwhile;
endif;
$html = ob_get_clean();
if ($html) {
echo $html;
}
?>
</div>
<div class=”secondo”>
<div class=”cover”>“><?php the_post_thumbnail(‘thumbnail’); ?></div>
</div>
<?php endwhile; ?>
<?php endif;
wp_reset_query();
?>