'widget_featured_posts widget_featured_posts_vertical widget_featured_meta', 'description' => __( 'Display latest posts or posts of specific category.', 'colormag' ), 'customize_selective_refresh' => true, ); $control_ops = array( 'width' => 200, 'height' => 250 ); parent::__construct( false, $name = __( 'TG: Featured Posts (Style 2)', 'colormag' ), $widget_ops ); } function form( $instance ) { $tg_defaults['title'] = ''; $tg_defaults['text'] = ''; $tg_defaults['number'] = 4; $tg_defaults['type'] = 'latest'; $tg_defaults['category'] = ''; $instance = wp_parse_args( ( array ) $instance, $tg_defaults ); $title = esc_attr( $instance['title'] ); $text = esc_textarea( $instance['text'] ); $number = $instance['number']; $type = $instance['type']; $category = $instance['category']; ?>

id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="latest" />
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="category" />

' ', 'name' => $this->get_field_name( 'category' ), 'selected' => $category, ) ); ?>

$number, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'post_status' => $post_status, ); // Display from category chosen. if ( $type == 'category' ) { $args['category__in'] = $category; } $get_featured_posts = new WP_Query( $args ); echo $before_widget; ?> ' . esc_html( $title ) . ''; } if ( ! empty( $text ) ) { ?>

have_posts() ):$get_featured_posts->the_post(); ?> '; } elseif ( $i == 2 ) { echo '
'; } ?>
ID ); $image_alt_text = get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true ); $title_attribute = get_the_title( $post->ID ); if ( empty( $image_alt_text ) ) { $image_alt_text = $title_attribute; } $image .= '
'; $image .= ''; $image .= get_the_post_thumbnail( $post->ID, $featured, array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $image_alt_text ), ) ) . ''; $image .= '
'; echo $image; } ?>

'; } ?> 2 ) { echo '
'; } // Reset Post Data wp_reset_query(); ?>