__( 'Displays posts with most comments.', 'newsmag' ), 'classname' => 'popular-posts', 'customize_selective_refresh' => true ) ); } public function widget( $args, $instance ) { $defaults = array( 'title' => __( 'Popular posts', 'newsmag' ), 'number' => 5, ); $instance = wp_parse_args( (array) $instance, $defaults ); $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $r = new WP_Query( array( 'posts_per_page' => $instance['number'], 'offset' => 0, 'orderby' => 'comment_count' ) ); wp_reset_postdata(); if ( $r->have_posts() ) : ?>
';
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail( get_the_ID(), 'newsmag-recent-post-list-image' );
}
$image_obj = array( 'id' => get_the_ID(), 'image' => $image );
$image = Newsmag_Helper::get_lazy_image( $image_obj );
?>