__('Display posts from a category', 'hueman'), 'classname' => 'widget_hu_posts' ) ); } public function hu_get_defaults() { return array( 'title' => '', // Posts 'posts_thumb' => 1, 'posts_category' => 1, 'posts_date' => 1, 'posts_num' => '4', 'posts_cat_id' => '0', 'posts_orderby' => 'date', 'posts_time' => '0', ); } /* Widget /* ------------------------------------ */ public function widget($args, $instance) { extract( $args ); $defaults = $this -> hu_get_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); $title = apply_filters('widget_title',$instance['title']); $title = empty( $title ) ? '' : $title; $output = $before_widget."\n"; if( $title || ! empty( $before_title) ) $output .= $before_title.$title.$after_title; ob_start(); ?> array( 'post' ), 'showposts' => $instance['posts_num'], 'cat' => $instance['posts_cat_id'], 'ignore_sticky_posts' => true, 'orderby' => $instance['posts_orderby'], 'order' => 'dsc', 'date_query' => array( array( 'after' => $instance['posts_time'], ) ) ) ); $posts = new WP_Query( is_array( $posts_query_params ) ? $posts_query_params : array() ); $date_format = apply_filters( 'hu_posts_widget_date_format', get_option( 'date_format' ) ); ?>