esc_html__( 'Displays posts in a two column layout.', 'hitmag' ), ) // Args ); } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { //print_r($instance); $defaults = array( 'title1' => esc_html__( 'Latest Posts', 'hitmag' ), 'category1' => '', 'number_posts1' => 3, 'sticky_posts1' => true, 'viewall_text1' => esc_html__( 'View All', 'hitmag' ), 'title2' => esc_html__( 'Latest Posts', 'hitmag' ), 'category2' => '', 'number_posts2' => 3, 'sticky_posts2' => true, 'viewall_text2' => esc_html__( 'View All', 'hitmag' ) ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

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

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


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

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

id_base ); $number_posts1 = ( ! empty( $instance['number_posts1'] ) ) ? absint( $instance['number_posts1'] ) : 3; $sticky_posts1 = ( isset( $instance['sticky_posts1'] ) ) ? $instance['sticky_posts1'] : true; $category1 = ( isset( $instance['category1'] ) ) ? absint( $instance['category1'] ) : ''; $viewall_text1 = ( ! empty( $instance['viewall_text1'] ) ) ? $instance['viewall_text1'] : ''; $title2 = ( ! empty( $instance['title2'] ) ) ? $instance['title2'] : ''; $title2 = apply_filters( 'widget_title', $title2 , $instance, $this->id_base ); $number_posts2 = ( ! empty( $instance['number_posts2'] ) ) ? absint( $instance['number_posts2'] ) : 3; $sticky_posts2 = ( isset( $instance['sticky_posts2'] ) ) ? $instance['sticky_posts2'] : true; $category2 = ( isset( $instance['category2'] ) ) ? absint( $instance['category2'] ) : ''; $viewall_text2 = ( ! empty( $instance['viewall_text2'] ) ) ? $instance['viewall_text2'] : ''; // Latest Posts 1 $latest_posts1 = new WP_Query( array( 'cat' => $category1, 'posts_per_page' => $number_posts1, 'post_status' => 'publish', 'ignore_sticky_posts' => $sticky_posts1, ) ); // Latest Posts 2 $latest_posts2 = new WP_Query( array( 'cat' => $category2, 'posts_per_page' => $number_posts2, 'post_status' => 'publish', 'ignore_sticky_posts' => $sticky_posts2, ) ); echo $before_widget; ?>
have_posts() ) : while ( $latest_posts1 -> have_posts() ) : $latest_posts1 -> the_post(); ?>
', '' ); ?>
have_posts() ) : while ( $latest_posts2 -> have_posts() ) : $latest_posts2 -> the_post(); ?>
', '' ); ?>