'widget-beginner-views widget_posts_thumbnail', 'description' => __( 'Display the most views posts with thumbnails.', 'beginner' ) ); // Create the widget. parent::__construct( 'beginner-views', // $this->id_base __( '» Most Views Posts Thumbnails', 'beginner' ), // $this->name $widget_options // $this->widget_options ); } /** * Outputs the widget based on the arguments input through the widget controls. * * @since 1.0.0 */ function widget( $args, $instance ) { extract( $args ); // Output the theme's $before_widget wrapper. echo $before_widget; // If the title not empty, display it. if ( $instance['title'] ) { echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; } // Posts query arguments. $args = array( 'post_type' => 'post', 'posts_per_page' => $instance['limit'], 'orderby' => 'meta_value_num', 'meta_key' => 'Views' ); // The post query $views = new WP_Query( $args ); global $post; if ( $views->have_posts() ) { echo '
id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" />
id="get_field_id( 'show_view' ); ?>" name="get_field_name( 'show_view' ); ?>" />