'awp_popular_post awp_widget', 'description' => __('Widget to display popular posts', 'awp') ); $control_ops = array( 'id_base' => 'awp_popular_post', 'width' => 200, 'height' => 250 ); parent::__construct('awp_popular_post', $name = __('AWP Popular Posts', 'awp'), $widget_ops, $control_ops ); } function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $post_count= apply_filters('widget_title', $instance['post_count']); global $author_id; // Display the widget title echo $args['before_widget']; if ( $title ){ echo $args['before_title'] .$title. $args['after_title']; } if($instance['sort_radio']=="comments") { $args = array( "posts_per_page" => $post_count, "post_type" => "post", "post_status" => "publish", "orderby" => "comment_count", "order" => "DESC" ); } else { $args = array( "posts_per_page" => $post_count, "post_type" => "post", "post_status" => "publish", "meta_key" => "wp_views", "orderby" => "meta_value_num", "order" => "DESC" ); } $asc_list = new WP_Query($args); if($asc_list->have_posts()) { echo "
value="views">
value="comments">
id="get_field_id('featured-image'); ?>" name="get_field_name('featured-image'); ?>" />
id="get_field_id('post-date'); ?>" name="get_field_name('post-date'); ?>" />
id="get_field_id('post-author'); ?>" name="get_field_name('post-author'); ?>" />
id="get_field_id('post-category'); ?>" name="get_field_name('post-category'); ?>" />
id="get_field_id('comments'); ?>" name="get_field_name('comments'); ?>" />
id="get_field_id('views'); ?>" name="get_field_name('views'); ?>" />
id="get_field_id('post-excerpt'); ?>" name="get_field_name('post-excerpt'); ?>" />