'asterisk_lite_slide_post_widget', 'description' => esc_html__('Displays articles from selected category in a slide.', 'asterisk-lite'), 'customize_selective_refresh' => true, ); $category_list = asterisk_lite_post_category_list(); $fields = array( 'title' => array( 'label' => esc_html__('Title:', 'asterisk-lite'), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__('Select Category:', 'asterisk-lite'), 'type' => 'select', 'options' => $category_list, ), 'post_number' => array( 'label' => esc_html__('Number of posts to show:', 'asterisk-lite'), 'type' => 'number', 'default' => 5, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 10, ), ); parent::__construct( 'asterisk-lite-slide-posts', esc_html__('Devs: Sidebar Slide Post Widget', 'asterisk-lite'), $opts, array(), $fields ); } /** * Outputs the content for the current widget instance. * * @since 1.0.0 * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. */ function widget( $args, $instance ){ $params = $this->get_params( $instance ); echo $args['before_widget']; $title = isset( $params['title'] ) ? $params['title'] : ''; $post_number = isset( $params['post_number'] ) ? $params['post_number'] : ''; $post_category = isset( $params['post_category'] ) ? $params['post_category'] : ''; if( $title ){ echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } $qargs = array( 'posts_per_page' => esc_attr( $post_number ), 'no_found_rows' => true, ); $rtl = ''; if( is_rtl() ){ $rtl = 'dir="rtl"'; } $slide_posts_query = new WP_Query( $qargs ); $count = 1; if ( $slide_posts_query->have_posts() ) : ?>