'widget-blogshare-category-posts widget-posts-thumbnail', 'description' => __( 'Display posts in selected category', 'blogshare' ) ); // Create the widget. parent::__construct( 'blogshare-category-posts', // $this->id_base __( '» Category Posts', 'blogshare' ), // $this->name $widget_options // $this->widget_options ); } /** * Outputs the widget based on the arguments input through the widget controls. * * @since 1.0.0 */ function widget( $args, $instance ) { // Default value. $defaults = array( 'title' => '', 'limit' => 6, 'show_number' => true ); $instance = wp_parse_args( (array) $instance, $defaults ); extract( $args ); // Output the theme's $before_widget wrapper. echo wp_kses_post( $before_widget ); // Theme prefix $prefix = 'blogshare-'; // Pull the selected category. $cat_id = isset( $instance['cat'] ) ? absint( $instance['cat'] ) : 0; // Get the category. $category = get_category( $cat_id ); // Get the category archive link. $cat_link = get_category_link( $cat_id ); // Limit to category based on user selected tag. if ( ! $cat_id == 0 ) { $args['cat'] = $cat_id; } ?> ' . esc_html( $instance['title'] ). '' ); } elseif ( $cat_id == 0 ) { echo ( '
id="get_field_id( 'show_number' ) ); ?>" name="get_field_name( 'show_number' ) ); ?>" />