'shuban_latest_posts_widget', 'description' => esc_html__('A widget to display recent posts as per your choice.', 'shuban') ); /* Widget control settings. */ $control_ops = array( 'width' => 350, 'height' => 350, 'id_base' => 'shuban_latest_posts_widget' ); /* Create the widget. */ parent::__construct( 'shuban_latest_posts_widget', esc_html__('ShubanPro - Latest Posts', 'shuban'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', $instance['title'] ); $categories = $instance['categories']; $number = $instance['number']; $date = $instance['date']; $query = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'cat' => $categories); $loop = new WP_Query($query); if ($loop->have_posts()) : /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; ?>
/>