esc_html__( 'Display Latest Posts.', 'buzznews' ), ) // Args ); } /** * Widget Form Section */ public function form( $instance ) { $defaults = array( 'title' => esc_html__( 'Latest Posts', 'buzznews' ), 'category' => esc_html__( 'all', 'buzznews' ), 'number_posts' => 6, ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

$this->get_field_name('category'), 'selected' => $instance['category'], 'show_option_all' => __('Show all posts','buzznews' ), 'class' => 'widefat' ) ); ?>

id_base ); $home_blog_category_id = ( ! empty( $instance['category'] ) ) ? absint( $instance['category'] ) : ''; $number_posts = ( ! empty( $instance['number_posts'] ) ) ? absint( $instance['number_posts'] ) : 6; // last post count if( $home_blog_category_id != '' ){ $category = get_category($home_blog_category_id); $last_page_count = ( $category->category_count ) / $number_posts; }else{ $last_page_count = intval( buzznews_get_total_posts() / $number_posts ) + 1; } // Latest Posts echo wp_kses_post( $before_widget ); ?>
'post','posts_per_page'=>$number_posts,'cat'=>$home_blog_category_id ); $blog_query = new WP_Query( $args ); while( $blog_query->have_posts()): $blog_query->the_post(); get_template_part( 'spiderbuzz/template-parts/home/grid-post' ); endwhile; wp_reset_postdata(); ?>