'recent_posts_c recent_posts_f clearfix', 'description' => __( 'Recent posts widget Type F - one category', 'awie') ); parent::__construct('recent_posts_f', __('Awye: Recent posts type F', 'awie'), $widget_ops); $this->alt_option_name = 'recent_posts_f'; add_action( 'save_post', array($this, 'flush_widget_cache') ); add_action( 'deleted_post', array($this, 'flush_widget_cache') ); add_action( 'switch_theme', array($this, 'flush_widget_cache') ); } public function widget($args, $instance) { $cache = array(); if ( ! $this->is_preview() ) { $cache = wp_cache_get( 'recent_posts_f', 'widget' ); } if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); $cat_one = isset( $instance['cat_one'] ) ? esc_attr($instance['cat_one']) : ''; $bg_color = isset( $instance['bg_color'] ) ? esc_attr($instance['bg_color']) : ''; $text_color = isset( $instance['text_color'] ) ? esc_attr($instance['text_color']) : ''; $first_query = new WP_Query( array( 'posts_per_page' => 1, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category_name' => $cat_one, ) ); $secound_query = new WP_Query( array( 'posts_per_page' => 4, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category_name' => $cat_one, 'offset' => 1, ) ); ?>