esc_html__( 'A Listed Post Widget', 'business-ezone' ), ) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $num_post = ! empty( $instance['num_post'] ) ? $instance['num_post'] : 3 ; $show_thumb = ! empty( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : ''; $show_date = ! empty( $instance['show_postdate'] ) ? $instance['show_postdate'] : ''; $listed_type = ! empty( $instance['listed_type'] ) ? $instance['listed_type'] : 'recent'; $post_args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $num_post, 'ignore_sticky_posts' => true, ); if( $listed_type == 'popular' ){ $post_args['orderby'] = 'comment_count'; } $qry = new WP_Query( $post_args ); if( $qry->have_posts() ){ echo $args['before_widget']; if( $title ) echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title']; ?>
/>
/>
> >