'caeliora_latest_news_widget', 'description' => esc_html__('A post widget that can display your latest posts, posts from a category, or hand-picked posts by ID.', 'caeliora') ); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'caeliora_latest_news_widget' ); /* Create the widget. */ parent::__construct( 'caeliora_latest_news_widget', esc_html__('Caeliora: Post Widget', 'caeliora'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); $layout = $instance['layout']; $categories = $instance['categories']; $number = $instance['number']; $counter = $instance['counter']; $date = $instance['date']; $postids = $instance['postids']; if($postids) { $postids = explode(',', $postids); $args_posts = array( 'showposts' => $number, 'post_type' => array('post', 'page'), 'post__in' => $postids, 'orderby' => 'post__in', 'ignore_sticky_posts' => 1 ); } else { $args_posts = array( 'showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'cat' => $categories ); } $loop = new WP_Query($args_posts); if ($loop->have_posts()) : $number_count = 0; /* Before widget (defined by themes). */ echo wp_kses_post( $args['before_widget'] ); /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) { echo wp_kses_post( $args['before_title'] . $title . $args['after_title'] ); } ?> have_posts()) : $loop->the_post(); ?>
__('Latest Posts', 'caeliora'), 'number' => 3, 'categories' => '', 'layout' => '', 'date' => false, 'counter' => false, 'postids' => ''); $instance = wp_parse_args( (array) $instance, $defaults ); ?>
/>
/>