'business-center-propopular-post', 'description' => esc_html__( 'Retrive top viewed posts.', 'business-center-pro' ), ); parent::__construct( 'business-center-propopular-post', esc_html__( 'TP : Popular Posts', 'business-center-pro' ), $tp_widget_popular_post ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { // outputs the content of the widget if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } $title = ( ! empty( $instance['title'] ) ) ? ( $instance['title'] ) : esc_html__( 'Popular', 'business-center-pro' ); $post_number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 3; $show_views_count = isset( $instance['show_views_count'] ) ? $instance['show_views_count'] : false; echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } $popular_args = new WP_Query( apply_filters( 'widget_posts_args', array( 'post_type' => 'post', 'posts_per_page' => $post_number, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true ) ) ); if ($popular_args->have_posts()) : ?>
id="get_field_id( 'show_views_count' ) ); ?>" name="get_field_name( 'show_views_count' ) ); ?>" />