'widget adore-widget latest-widget', 'description' => __( 'Retrive Latest Posts Widgets', 'archive-news' ), ); parent::__construct( 'archive_news_latest_posts_widget', __( 'Adore Widget: Latest Posts Widget', 'archive-news' ), $latest_posts_widget ); } /** * 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 ) { if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } $latest_posts_title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : ''; $latest_posts_title = apply_filters( 'widget_title', $latest_posts_title, $instance, $this->id_base ); $viewall_button_label = ( ! empty( $instance['view_all_button_label'] ) ) ? $instance['view_all_button_label'] : ''; $latest_posts_post_count = isset( $instance['number'] ) ? absint( $instance['number'] ) : 4; $latest_posts_post_offset = isset( $instance['offset'] ) ? absint( $instance['offset'] ) : ''; $latest_posts_category = isset( $instance['category'] ) ? absint( $instance['category'] ) : ''; $viewall_button_link = ( ! empty( $instance['view_all_button_link'] ) ) ? $instance['view_all_button_link'] : esc_url( get_category_link( $latest_posts_category ) ); echo $args['before_widget']; if ( ! empty( $latest_posts_title || $viewall_button_label ) ) { ?>
'post', 'posts_per_page' => absint( $latest_posts_post_count ), 'offset' => absint( $latest_posts_post_offset ), 'cat' => absint( $latest_posts_category ), ); $query = new WP_Query( $latest_posts_widgets_args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

4 ) { $instance['number'] = 4; } $instance['offset'] = (int) $new_instance['offset']; $instance['category'] = (int) $new_instance['category']; return $instance; } } }