function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'Recent Posts' : $instance['title'], $instance, $this->id_base); if (!($number = absint($instance['number']))) { $number = 4; } if (!($cats = $instance["cats"])) { $cats = ''; } // array to call recent posts. $themeloy_args = array('showposts' => $number, 'category__in' => $cats); $themeloy_widget = null; $themeloy_widget = new WP_Query($themeloy_args); echo $before_widget; // Widget title echo $before_title; echo $instance["title"]; echo $after_title; // Post list in widget $i = 0; ?> <div class="widget_container"> <?php while ($themeloy_widget->have_posts()) { $themeloy_widget->the_post(); $post_id = get_the_ID(); $i++; $thumb = themeloy_get_thumbnail(get_the_ID()); if ($i == 1) { ?> <div class="main_post"> <div class="image_post feature-item"> <a href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'main-square'); ?> <img src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img src="' . get_template_directory_uri() . '/images/demo/main-square.jpg' . '">'; } ?> </a> <span class="caption"> <?php $post_cat = get_post_custom_values('cat_themeloy_select', get_the_ID()); $post_cat = $post_cat[0] != '' ? $post_cat[0] : of_get_option('blog_category_post'); if ($post_cat == '1') { echo '<p class="cat-slider">'; echo the_category(', ') . '</p>'; } ?> <a href="<?php the_permalink(); ?> "> <span><?php the_title(); ?> </span></a> </span> <?php echo themeloy_post_type(); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> </div> <?php echo themeloy_post_meta(get_the_ID()); ?> <p> <?php echo themeloy_short_title(300, get_the_excerpt('')); ?> </p> </div> <div class="list_post_vertical"> <ul> <?php } else { ?> <li> <?php $post_date = get_post_custom_values('date_themeloy_select', get_the_ID()); $post_date = $post_date[0] != '' ? $post_date[0] : of_get_option('blog_date_post'); if ($post_date == '1') { ?> <div class="feature_post_style"> <span class="post_date"><span class="date_number"><?php echo get_the_date('d'); ?> </span> <?php echo get_the_date('M'); ?> <i class="icon-caret-right feature-icon-right"></i> </span> <span class="post_time"><i class="icon-time"></i> <?php echo get_the_time('H:i'); ?> </span> </div> <?php } ?> <div class="feature-link feature-item"> <a href="<?php the_permalink(); ?> " class="feature-link"> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'medium-feature'); ?> <img src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img src="' . get_template_directory_uri() . '/images/demo/medium-feature.jpg' . '">'; } ?> </a> <?php echo themeloy_post_type(); ?> </div> <div class="list_desc"> <h4 class="list_title"><a class="post-title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title_attribute(); ?> "> <?php the_title(); ?> </a></h4> <?php echo themeloy_feature_post_meta(get_the_ID()); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> </div> <div class="clear"></div> </li> <?php } } ?> </ul> </div> </div> <?php wp_reset_query(); echo $after_widget; }
function block($instance) { extract($instance); $titles = apply_filters('widget_title', empty($instance['titles']) ? 'Recent Posts' : $instance['titles'], $instance, $this->id_base); $show_style_1 = isset($instance['show_style_1']) ? $instance['show_style_1'] : false; if (!isset($instance["cats"])) { $cats = ''; } // array to call recent posts. $themeloy_args = array('showposts' => $number_show, 'category__in' => $cats); $themeloy_widget = null; $themeloy_widget = new WP_Query($themeloy_args); ?> <div class="widget post_list_medium_widget"> <?php if (!empty($instance['titles'])) { ?> <h3 class="widget-title"><span><?php echo $instance["titles"]; ?> </span></h3><?php } ?> <div class="widget_container"> <ul class="<?php if ($show_style_1 == true) { echo "post_list_medium_style1"; } else { echo "post_list_medium"; } ?> "> <?php $row_count = 0; while ($themeloy_widget->have_posts()) { $row_count++; $themeloy_widget->the_post(); $post_id = get_the_ID(); $thumb = themeloy_get_thumbnail(get_the_ID()); ?> <li class="list_item <?php if ($row_count % 2 == 0) { echo "left-column-post"; } ?> "> <div class="entry-thumb feature-item"> <a href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'feature-large'); ?> <img class="cat-feature-large-img" src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img class="cat-feature-large-img" src="' . get_template_directory_uri() . '/images/demo/feature-large.jpg' . '">'; } ?> </a> <div class="cat-feature-large"> <?php $post_cat = get_post_custom_values('cat_themeloy_select', get_the_ID()); $post_cat = $post_cat[0] != '' ? $post_cat[0] : of_get_option('blog_category_post'); if ($post_cat == '1') { echo '<p class="cat-slider">'; echo the_category(', ') . '</p>'; } ?> </div> <?php echo themeloy_post_type(); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> </div> <h3><a href="<?php the_permalink(); ?> " class="title"><?php the_title(); ?> </a></h3> <?php $enable_review = get_post_custom_values('reviewthemeloy_checkbox', get_the_ID()); ?> <?php if (of_get_option('disable_review') == 0) { if ($enable_review[0] == 1) { ?> <span class="review-wrap"> <span class="review-star"> <span style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %" class="review-star-inline"> </span> </span> </span> <?php } else { ?> <span class="review-wrap"> <span class="review-star-none"> <span class="review-star-inline-none"></span> </span> </span> <?php } } else { ?> <span class="review-wrap"> <span class="review-star-none"> <span class="review-star-inline-none"></span> </span> </span> <?php } ?> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php if ($show_style_1 == true) { } else { ?> <p><?php echo themeloy_short_title(320, get_the_excerpt('')); ?> </p> <?php } ?> <div class="clear"></div> </li> <?php } ?> </ul> </div> </div> <?php wp_reset_query(); }
function block($instance) { extract($instance); $titles = apply_filters('widget_title', empty($instance['titles']) ? 'Recent Posts' : $instance['titles'], $instance, $this->id_base); $title1 = apply_filters('widget_title', empty($instance['title1']) ? 'Recent Posts' : $instance['title1'], $instance, $this->id_base); if (!($number_show = absint($instance['number_show']))) { $number_show = 5; } if (!isset($instance["cats"])) { $cats = ''; } if (!isset($instance["cats1"])) { $cats1 = ''; } // array to call recent posts. $themeloy_args = array('showposts' => $number_show, 'category__in' => $cats); $themeloy_args1 = array('showposts' => $number_show, 'category__in' => $cats1); $themeloy_widget = null; $themeloy_widget = new WP_Query($themeloy_args); echo '<div class="widget two_columns_post">'; $i = 0; while ($themeloy_widget->have_posts()) { $themeloy_widget->the_post(); $i++; $post_id = get_the_ID(); if ($i == 1) { ?> <div class="main-post-col1"> <?php if (!empty($instance['titles'])) { ?> <h3 class="widget-title"><span><?php echo $instance["titles"]; ?> </span></h3><?php } ?> <div class="two-content-wrapper"> <div class="image_review_wrapper"> <div class="entry-thumb feature-item"> <a href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'feature-large'); ?> <img class="cat-feature-large-img" src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img class="cat-feature-large-img" src="' . get_template_directory_uri() . '/images/demo/feature-large.jpg' . '">'; } ?> </a> <div class="cat-feature-large"> <?php $post_cat = get_post_custom_values('cat_themeloy_select', get_the_ID()); $post_cat = $post_cat[0] != '' ? $post_cat[0] : of_get_option('blog_category_post'); if ($post_cat == '1') { echo '<p class="cat-slider">'; echo the_category(', ') . '</p>'; } ?> </div> <?php echo themeloy_post_type(); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> </div> </div> <div class="feature-text-col"> <div class="post-title"><h3><a class="title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "> <?php the_title(); ?> </a></h3></div> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php echo themeloy_short_title(190, get_the_excerpt()); ?> </div> <?php } else { ?> <div class="small-feature"> <?php $post_date = get_post_custom_values('date_themeloy_select', get_the_ID()); $post_date = $post_date[0] != '' ? $post_date[0] : of_get_option('blog_date_post'); if ($post_date == '1') { ?> <div class="feature_post_style"> <span class="post_date"><span class="date_number"><?php echo get_the_date('d'); ?> </span> <?php echo get_the_date('M'); ?> <i class="icon-caret-right feature-icon-right"></i> </span> <span class="post_time"><i class="icon-time"></i> <?php echo get_the_time('H:i'); ?> </span> </div> <?php } ?> <div class="feature-link feature-item"> <a href="<?php the_permalink(); ?> " class="feature-link"> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'medium-feature'); ?> <img src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img src="' . get_template_directory_uri() . '/images/demo/medium-feature.jpg' . '">'; } ?> </a> <?php echo themeloy_post_type(); ?> </div> <div class="feature-text"> <div class="post-title"><h4 class="list_title"> <a class="title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "> <?php the_title(); ?> </a></h4></div> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> <div class="clear"></div> </div> </div> <?php } } ?> </div> </div> <?php wp_reset_query(); // column right $themeloy_widget1 = null; $themeloy_widget1 = new WP_Query($themeloy_args1); $i = 0; while ($themeloy_widget1->have_posts()) { $themeloy_widget1->the_post(); $i++; $post_id = get_the_ID(); $thumb = themeloy_get_thumbnail(get_the_ID()); if ($i == 1) { ?> <div class="main-post-col2"> <?php if (!empty($instance['title1'])) { ?> <h3 class="widget-title"><span><?php echo $instance["title1"]; ?> </span></h3><?php } ?> <div class="two-content-wrapper"> <div class="image_review_wrapper"> <div class="entry-thumb feature-item"> <a href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'feature-large'); ?> <img class="cat-feature-large-img" src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img class="cat-feature-large-img" src="' . get_template_directory_uri() . '/images/demo/feature-large.jpg' . '">'; } ?> </a> <div class="cat-feature-large"> <?php $post_cat = get_post_custom_values('cat_themeloy_select', get_the_ID()); $post_cat = $post_cat[0] != '' ? $post_cat[0] : of_get_option('blog_category_post'); if ($post_cat == '1') { echo '<p class="cat-slider">'; echo the_category(', ') . '</p>'; } ?> </div> <?php echo themeloy_post_type(); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> </div> </div> <div class="feature-text-col"> <div class="post-title"><h3><a class="title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "> <?php the_title(); ?> </a></h3></div> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php echo themeloy_short_title(190, get_the_excerpt()); ?> </div> <?php } else { $date = '<span class="date">' . get_the_date('M d, Y') . '</span>'; ?> <div class="small-feature"> <?php $post_date = get_post_custom_values('date_themeloy_select', get_the_ID()); $post_date = $post_date[0] != '' ? $post_date[0] : of_get_option('blog_date_post'); if ($post_date == '1') { ?> <div class="feature_post_style"> <span class="post_date"><span class="date_number"><?php echo get_the_date('d'); ?> </span> <?php echo get_the_date('M'); ?> <i class="icon-caret-right feature-icon-right"></i> </span> <span class="post_time"><i class="icon-time"></i> <?php echo get_the_time('H:i'); ?> </span> </div> <?php } ?> <div class="feature-link feature-item"> <a href="<?php the_permalink(); ?> " class="feature-link"> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'medium-feature'); ?> <img src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img src="' . get_template_directory_uri() . '/images/demo/medium-feature.jpg' . '">'; } ?> </a> <?php echo themeloy_post_type(); ?> </div> <div class="feature-text"> <div class="post-title"><h4 class="list_title"><a class="title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "> <?php the_title(); ?> </a></h4></div> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> <div class="clear"></div> </div> </div> <?php } } ?> </div> </div> </div> <?php wp_reset_query(); }
function block($instance) { extract($instance); $titles = apply_filters('widget_title', empty($instance['titles']) ? 'Recent Posts' : $instance['titles'], $instance, $this->id_base); $show_style_1 = isset($instance['show_style_1']) ? $instance['show_style_1'] : false; if (!($number_show = absint($instance['number_show']))) { $number_show = 4; } if (!isset($instance["cats"])) { $cats = ''; } // array to call recent posts. $themeloy_args = array('showposts' => $number_show, 'category__in' => $cats); $themeloy_widget = null; $themeloy_widget = new WP_Query($themeloy_args); // Widget title // Post list in widget ?> <div class="widget post_grid_list_widget"> <?php if (!empty($instance['titles'])) { ?> <h3 class="widget-title"><span><?php echo $instance["titles"]; ?> </span></h3><?php } ?> <div class="widget_container"> <ul class="<?php if ($show_style_1 == true) { echo " post_grid_list_style1"; } else { echo " post_grid_list"; } ?> "> <?php while ($themeloy_widget->have_posts()) { $themeloy_widget->the_post(); $post_id = get_the_ID(); $thumb = themeloy_get_thumbnail(get_the_ID()); ?> <li class="list_item feature-item"> <a class="entry-thumb" href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'main-square'); ?> <img src="<?php echo $image[0]; ?> " /> <?php } else { echo '<img src="' . get_template_directory_uri() . '/images/demo/main-square.jpg' . '">'; } ?> </a> <?php if ($show_style_1 == false) { ?> <h4 class="caption"> <?php $post_cat = get_post_custom_values('cat_themeloy_select', get_the_ID()); $post_cat = $post_cat[0] != '' ? $post_cat[0] : of_get_option('blog_category_post'); if ($post_cat == '1') { echo '<p class="cat-slider">'; echo the_category(', ') . '</p>'; } ?> <span> <a class="entry-thumb" href="<?php the_permalink(); ?> "> <?php the_title(); ?> </a></span></h4><?php } ?> <?php $post_review = get_post_custom_values('enable_review_themeloy_select', $post_id); $post_review = $post_review[0] != '' ? $post_review[0] : of_get_option('enable_all_review'); $total_review = absint(themeloy_get_total_review($post_id)); if ($post_review == '1') { ?> <div class="ratings"> <div class="rating-box"> <div class="rating" style="width:<?php echo themeloy_get_total_review(get_the_ID()); ?> %"></div> </div> </div> <?php } ?> <?php echo themeloy_post_type(); ?> <?php if ($show_style_1 == true) { ?> <h4 class="caption"><a href="<?php the_permalink(); ?> " class="title"><span><?php the_title(); ?> </span></a></h4><?php } ?> <?php echo themeloy_post_meta(get_the_ID()); ?> <?php if ($show_style_1 == true) { ?> <p><?php echo themeloy_short_title(320, get_the_excerpt('')); ?> </p> <?php } ?> <div class="clear"></div> <?php } ?> </ul> <div class="clear"></div> </div> </div> <?php wp_reset_query(); }