<?php
//https://wp-kama.ru/function/wp_query#parametry-daty-vremeni
?>
<!-- the most popular START -->
<div class="widget">
<h3>Интересные материалы</h3>
<!-- previews -->
<?php
// args
wp_reset_postdata();
// Создадим новую функцию которая добавит условие where в запрос
function filter_where( $where = '' ) {
// за последние 30 дней
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
$args = array(
'cat' => 0,
'showposts' => 5,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
);
$the_query = new WP_Query( $args );
remove_filter( 'posts_where', 'filter_where' );
?>
<!-- 3009 -->
<?php if( $the_query->have_posts() ): ?>
<ul class="previews-list">
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li>
<!-- post date -->
<!-- <?php echo get_the_date(); ?> -->
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php
if ( has_post_thumbnail() ) { ?>
<div class="preview-img">
<?php the_post_thumbnail( array( 68, 68, 'bfi_thumb' => true ) ); ?>
</div>
<?php } ?>
<div class="preview-text"><?php the_title(); ?></div>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<!-- 3009 -->
<!-- the most popular END -->
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>