defaults = array( 'title' => esc_attr__( 'Posts', 'essential-widgets' ), 'post_type' => array( 'post' ), 'order' => 'DESC', 'orderby' => 'date', 'number' => 10, 'show_date' => false, 'show_author' => false ); $widget_ops = array( 'classname' => 'essential-widgets ew-posts ewposts', 'description' => esc_html__( 'Displays a list of posts.', 'essential-widgets' ), ); $control_ops = array( 'id_base' => 'ew-posts', ); parent::__construct( 'ew-posts', // Base ID esc_html__( 'EW: Posts', 'essential-widgets' ), // Name $widget_ops, $control_ops ); } /** * Displays the widget control options in the Widgets admin screen. * * @since 1.0.0 * @access public * @param array $instance * @param void */ public function form( $instance ) { // Merge the user-selected arguments with the defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); //

defaults ); $loop = new \WP_Query( array( 'posts_per_page' => $instance['number'], 'post_type' => $instance['post_type'], 'order' => $instance['order'], 'orderby' => $instance['orderby'], 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ) ); if ( $loop->have_posts() ) : ?> id_base ) . $args['after_title']; ?>