I am a WP developer with just little if none knowledge of PHP.
Yet I have to use a code snippet on a website to select posts with a date within a range.
Browsing around I found the following but I see all the results -no filtering.
// args
$args = array(
'numberposts' => -1,
'post_type' => 'contenuto',
'meta_query' => [
'key' => 'data_contenuto',
'value' => ['2000-01-01', '2000-12-31'],
'compare' => 'BETWEEN',
]
);
// query
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<p><?php the_title();?></p>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>