defaults = array( 'latest_text' => esc_html__( 'Latest From: ', 'digimag-lite' ), 'excerpt_length' => 25, 'category_1' => -1, 'category_2' => -1, 'category_3' => -1, 'category_4' => -1, ); parent::__construct( 'digimag-category-posts', esc_html__( 'Digimag Lite: Category Posts', 'digimag-lite' ), array( 'classname' => 'digimag-category-posts', 'description' => esc_html__( 'A widget that displays your latest posts from chosen categories', 'digimag-lite' ), ) ); } /** * Widget form. * * @param array $instance Widget instance. * * @return void */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); $latest_text = $instance['latest_text']; $excerpt_length = $instance['excerpt_length']; $category_1 = $instance['category_1']; $category_2 = $instance['category_2']; $category_3 = $instance['category_3']; $category_4 = $instance['category_4']; $cats = array( $category_1, $category_2, $category_3, $category_4 ); ?>

$cat ) : ?>

esc_html__( 'Select', 'digimag-lite' ), 'name' => $this->get_field_name( 'category_' . ( $index + 1 ) ), 'selected' => $cat, ) ); ?>

defaults ); $latest_text = $instance['latest_text']; $excerpt_length = $instance['excerpt_length']; $category_1 = intval( $instance['category_1'] ); $category_2 = intval( $instance['category_2'] ); $category_3 = intval( $instance['category_3'] ); $category_4 = intval( $instance['category_4'] ); $cat_ids = array( $category_1, $category_2, $category_3, $category_4 ); echo $args['before_widget']; // WPCS: XSS OK. ?>
$cat_id, 'posts_per_page' => 1, ); $query = new WP_Query( $arguments ); while ( $query->have_posts() ) : $query->the_post(); ?>