'widget_latest_post', 'description' => esc_html__( 'Retrive latest posts.', 'bloz' ), ); parent::__construct( 'bloz_latest_post', esc_html__( 'TO : Latest Posts', 'bloz' ), $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'] ) : ''; $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $category = isset( $instance['category'] ) ? absint( $instance['category'] ) : ''; echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } $popular_args = array( 'post_type' => 'post', 'posts_per_page' => absint($number), 'order' => 'DESC', 'cat' => absint( $category ), ); echo '
';
endif;
?>