'trending-post-section ascendoor-widget', 'description' => __( 'Retrive Trending Posts Widgets', 'bright-news' ), ); parent::__construct( 'bright_news_trending_posts_widget', __( 'Ascendoor Trending Posts Widget', 'bright-news' ), $bright_news_grid_widget_ops ); } /** * 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; } $trending_posts_title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : ''; $trending_posts_title = apply_filters( 'widget_title', $trending_posts_title, $instance, $this->id_base ); $trending_posts_button_label = ( ! empty( $instance['button_label'] ) ) ? $instance['button_label'] : ''; $trending_posts_post_offset = isset( $instance['offset'] ) ? absint( $instance['offset'] ) : ''; $trending_posts_category = isset( $instance['category'] ) ? absint( $instance['category'] ) : ''; $trending_posts_button_link = ( ! empty( $instance['button_link'] ) ) ? $instance['button_link'] : esc_url( get_category_link( $trending_posts_category ) ); echo $args['before_widget']; if ( ! empty( $trending_posts_title || $trending_posts_button_label ) ) { ?>
'post', 'posts_per_page' => absint( 5 ), 'offset' => absint( $trending_posts_post_offset ), 'cat' => absint( $trending_posts_category ), ); $query = new WP_Query( $trending_posts_widgets_args ); if ( $query->have_posts() ) : $i = 1; while ( $query->have_posts() ) : $query->the_post(); ?>