'advance_blog_recent_post_widget', 'description' => esc_html__('Displays post form selected category specific for popular post in sidebars.', 'advance-blog'), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__('Title:', 'advance-blog'), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__('Select Category:', 'advance-blog'), 'type' => 'dropdown-taxonomies', 'show_option_all' => esc_html__('All Categories', 'advance-blog'), ), 'enable_counter' => array( 'label' => esc_html__('Enable Counter:', 'advance-blog'), 'type' => 'checkbox', 'default' => true, ), 'post_number' => array( 'label' => esc_html__('Number of Posts:', 'advance-blog'), 'type' => 'number', 'default' => 4, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 9, ), ); parent::__construct('advance-blog-popular-sidebar-layout', esc_html__('Advance Blog: Recent Widget', 'advance-blog'), $opts, array(), $fields); } /** * Outputs the content for the current widget instance. * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. * @since 1.0.0 * */ function widget($args, $instance) { $params = $this->get_params($instance); echo $args['before_widget']; if (!empty($params['title'])) { echo $args['before_title'] . esc_html($params['title']) . $args['after_title']; } $qargs = array( 'posts_per_page' => esc_attr($params['post_number']), 'no_found_rows' => true, ); if (absint($params['post_category']) > 0) { $qargs['cat'] = absint($params['post_category']); } $recent_posts_query = new WP_Query($qargs); $count = 1; if ($recent_posts_query->have_posts()) : ?>