__( '(News style) Displays latest posts or posts from a choosen category. ', 'best-blog' ), 'customize_selective_refresh' => true, ) ); } /** * Display Widget * * @param $args * @param $instance */ function widget($args, $instance) { extract($args); $number_posts = ( ! empty( $instance['number_posts'] ) ) ? absint( $instance['number_posts'] ) : 3; $sticky_posts = ( isset( $instance['sticky_posts'] ) ) ? $instance['sticky_posts'] : true; $category = ( isset( $instance['category'] ) ) ? absint( $instance['category'] ) : ''; $viewall_text = ( ! empty( $instance['viewall_text'] ) ) ? $instance['viewall_text'] : ''; // Latest Posts 1 $latest_big_posts = new WP_Query( array( 'cat' => $category, 'posts_per_page' => 1, 'post_status' => 'publish', 'ignore_sticky_posts' => $sticky_posts, ) ); echo $before_widget; ?>

have_posts() ) : while ( $latest_big_posts -> have_posts() ) : $latest_big_posts -> the_post(); ?> $category, 'posts_per_page' => $number_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => $sticky_posts, 'post__not_in' => $firstPosts, ) ); ?> have_posts() ) : while ( $latest_list_posts -> have_posts() ) : $latest_list_posts -> the_post(); ?> cat_name; $category_link = get_category_link( $first_cat->cat_ID ); ?>
'show_option_all', 'title' => 'Latest News', 'sticky_posts' => 'true', 'number_posts' => '5', 'viewall_text' => 'View All', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

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

class="checkbox" id="get_field_id('sticky_posts'); ?>" name="get_field_name('sticky_posts'); ?>" />