I’m using a theme that shows popular posts with the code below, and I need
someone to help me edit this code to make it show popular posts on the last week or
month.
<?php
$args = array();
$args['posts_per_page'] = $number_posts;
$args['orderby'] = 'comment_count';
$args['order'] = 'DESC';
$query = new WP_Query($args);
while($query->have_posts() ) : $query->the_post(); global $post; ?>
<li>
<a title="<?php the_title();?>" href="<?php the_permalink();?>">
<figure>
<?php if(has_post_thumbnail() ) { ?>
<a href="<?php the_permalink();?>">
<img src="<?php echo aq_resize(wp_get_attachment_url( get_post_thumbnail_id($post->ID) ), 42, 42, true); ?>" alt="<?php the_title();?>" />
</a>
<?php } else { ?>
<a href="<?php the_permalink();?>">
<img src="<?php echo get_template_directory_uri() . '/img/missing_56.png';?>" alt="<?php the_title();?>" />
</a>
<?php } ?>
</figure>
<p>
<a href="<?php the_permalink();?>"><?php the_title();?></a> <br />
<span> <?php _e('Le ', 'Voxis'); the_time("F d, Y");?>, <?php comments_popup_link(esc_html__('0 commentaires','Voxis'), esc_html__('1 commentaire','Voxis'), '% '.esc_html__('commentaires','Voxis')); ?> </span>
</p>
</a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
I have not yet tested below code but will assure that this will work for you.