esc_html__('This Widget show Category Posts From Multiple Category.', 'allrounder-news') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $allrounder_news_Category_list = allrounder_news_Category_list($select = false); $fields = array( 'allrounder_news_blog_cat_category' => array( 'allrounder_news_widgets_name' => 'allrounder_news_blog_cat_category', 'allrounder_news_widgets_title' => esc_html__('Select Post Categories', 'allrounder-news'), 'allrounder_news_widgets_field_type' => 'multicheckboxes', 'allrounder_news_widgets_field_options' => $allrounder_news_Category_list ), 'allrounder_news_blog_posts' => array( 'allrounder_news_widgets_name' => 'allrounder_news_blog_posts', 'allrounder_news_widgets_title' => esc_html__('Posts Per Page', 'allrounder-news'), 'allrounder_news_widgets_field_type' => 'number', ), ); return $fields; } /** * 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) { extract($args); $allrounder_news_blog_cat_categories = isset( $instance['allrounder_news_blog_cat_category'] ) ? $instance['allrounder_news_blog_cat_category'] : '' ; $allrounder_news_blog_posts = isset( $instance['allrounder_news_blog_posts'] ) ? $instance['allrounder_news_blog_posts'] : '5' ; if( empty( $allrounder_news_blog_posts ) ){ $allrounder_news_blog_posts = 5; } echo $before_widget; if( $allrounder_news_blog_cat_categories ){ ?>
$value){ $multiple_cat_posts = new WP_Query( array( 'post_type' => 'post','posts_per_page' => $allrounder_news_blog_posts,'category_name' => $key) ); if( $multiple_cat_posts->have_posts() ){ ?>

Popular News

have_posts() ){ $multiple_cat_posts->the_post(); if($post_count == '1'){ ?>

widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$allrounder_news_widgets_name] = allrounder_news_widgets_updated_field_value($widget_field, $new_instance[$allrounder_news_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $allrounder_news_widgets_field_value = !empty($instance[$allrounder_news_widgets_name]) ? $instance[$allrounder_news_widgets_name] : ''; allrounder_news_widgets_show_widget_field($this, $widget_field, $allrounder_news_widgets_field_value); } } }