'gum_grid_block_1', 'description' => __('Posts block 1', 'bloom-feminine'));
parent::__construct('homepage-main1', __('Posts Grid 1', 'bloom-feminine'), $widget_ops);
}
function widget($args, $instance) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$category = isset($instance['category']) ? $instance['category'] : '';
$tags = empty($instance['tags']) ? '' : $instance['tags'];
$postcount = empty($instance['postcount']) ? '6' : $instance['postcount'];
$offset = empty($instance['offset']) ? '' : $instance['offset'];
$sticky = isset($instance['sticky']) ? $instance['sticky'] : 0;
$show_cat = isset($instance['show_cat']) ? $instance['show_cat'] : 0;
$show_date = isset($instance['show_date']) ? $instance['show_date'] : 1;
echo $before_widget;
if (!empty( $title)) { echo $before_title .'
' . $after_title; } ?>
$postcount, 'offset' => $offset, 'cat' => $category, 'tag' => $tags, 'ignore_sticky_posts' => $sticky);
$counter = 1;
$the_query = new WP_Query($args);
if($the_query->have_posts()):
$count = 0;
$remaining_posts = '';
$first_grid_post= '';
$image_sizeIs='';
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_id = get_the_ID();
$post_title = get_the_title();
$post_title = wp_trim_words($post_title, 7, '...');
if($count < 2){$image_sizeIs='gum_bloom_400X240';}
else{$image_sizeIs='gum_bloom_150X90';}
$img_src= '';
if ( has_post_thumbnail($post_id ) ) {
$post_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $image_sizeIs );
$img_src = $post_image[0];
}
$post_permalink = get_the_permalink();
$excerpt = wp_trim_words(get_the_excerpt(), 20, '...');
$author1=get_the_author();
$post_date = get_the_date('M d, Y');
$post_categories = wp_get_post_categories( $post_id );
$cat_html = '';
if(!empty($post_categories)){
foreach($post_categories as $post_category){
$cat = get_category( $post_category );
$cat_html .= ''.esc_html($cat->name).'';
}
}
if($show_cat != 1 ) $cat_html ='';
$date_li='';
if($show_date == 1) $date_li = ''.$post_date.'';
if($count < 2){
$first_grid_post .= '
'.esc_html($author1).'
'.esc_html($post_date).'
';
} // count==0
else{
if($count == 2 || $count == 4){
$remaining_posts .= '';
}
$remaining_posts .= '
';
if($count == 3 || $count == 5){
$remaining_posts .='
';
}
}
$count++;
endwhile;
wp_reset_postdata();
?>
'', 'category' => '', 'tags' => '','sticky' => 0, 'offset' => 0, 'show_cat' => 1, 'show_date'=>1);
$instance = wp_parse_args((array) $instance, $defaults); ?>
/>
/>
/>