break; } } } ?> </ul> </div> </header> <?php if (has_post_thumbnail()) { $exp1 = empty($post_format) && $metadata['thumb']; $exp2 = $post_format && $metadata['thumb_other']; if ($exp1 || $exp2) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_06'); ?> <div class="kp-thumb pull-right"> <img src="<?php echo $image_croped; ?> " alt="" /> </div> <?php } } ?> <div class="clearfix entrycontent"> <?php the_content();
function kopa_load_timeline_posts_fn($month, $year, $paged) { $args = array('date_query' => array('post_type' => array('post'), 'post_status' => array('publish'), 'ignore_sticky_posts' => true, array('year' => $year, 'month' => $month))); if ($paged) { $args['paged'] = $paged; } $posts = new WP_Query($args); $exceprt_type = KopaOptions::get_option('exceprt_type', 'limit'); $excerpt_limit = KopaOptions::get_option('excerpt_limit', 200, 'Int'); $metadata = array(); $metadata['date'] = false; $metadata['comments'] = KopaOptions::get_option('is_display_comments', true, 'Boolean'); $metadata['views'] = KopaOptions::get_option('is_display_views', true, 'Boolean'); $metadata['likes'] = KopaOptions::get_option('is_display_likes', true, 'Boolean'); $metadata['readmore'] = KopaOptions::get_option('is_display_readmore', true, 'Boolean'); global $post; while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); $post_format = get_post_format(); if (!is_sticky()) { ?> <div class="item clearfix"> <p class="kopa-timeline-date-small"><?php echo get_the_date(); ?> </p> <?php if (has_post_thumbnail()) { $image_full = KopaImage::get_post_image_src($post_id, 'full'); $image_croped = KopaImage::get_post_image_src($post_id, 'size_09'); ?> <div class="kopa-thumb"> <img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "/> <div class="mask"></div> <a href="<?php echo $post_url; ?> " class="icon-link fa fa-link fa-flip-horizontal"></a> <span class="icon-zoom-in fa fa-search-plus" onclick="KopaLightbox.open_image('<?php echo $image_full; ?> ');"></span> </div> <?php } ?> <div class="kp-caption"> <h4 class="post-title"><a href="<?php echo $post_url; ?> " title="<?php echo $post_title; ?> "><?php echo $post_title; ?> </a></h4> <ul class="kp-meta-post list-inline"> <?php $is_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_first ? 'metadata-first' : ''; $is_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; case 'comments': ?> <li class="<?php echo $class; ?> "><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> <?php break; case 'views': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true)); break; case 'likes': printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true)); break; } } } ?> </ul> <?php if ('excerpt' == $exceprt_type) { if (has_excerpt()) { printf('<p>%s</p>', get_the_excerpt()); } else { global $post; if (strpos($post->post_content, '<!--more-->')) { the_content(' '); } else { printf('<p>%s</p>', get_the_excerpt()); } } } elseif ('full' == $exceprt_type) { global $more; $more = true; the_content(); } else { if ($excerpt_limit) { $excerpt = KopaUtil::substr($post->post_content, $excerpt_limit); echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : ''; } } ?> <?php if ($metadata['readmore'] && 'full' != $exceprt_type) { ?> <a href="<?php echo $post_url; ?> " class="read-more"><?php _e('Read more', kopa_get_domain()); ?> </a> <?php } ?> </div> <!-- kp-caption --> <div class="more-i"> <div class="more-time"> <span><?php echo get_the_date('M d'); ?> </span> <i><?php echo get_the_date('Y'); ?> </i> </div> <span></span> <?php echo KopaIcon::getIconPostFormat($post_format); ?> </div> <!-- more i --> </div> <?php } } wp_reset_postdata(); }
<img class="img-responsive" src="<?php echo $image; ?> " alt="<?php echo $post_title; ?> "> </a> </div> <?php } } } else { if (has_post_thumbnail()) { $size = 0 == $loop_index ? 'size_09' : 'size_13'; $image = KopaImage::get_post_image_src($post_id, $size); ?> <div class="kopa-post-content-formated pull-left"> <a href="<?php echo $post_url; ?> "> <img class="img-responsive" src="<?php echo $image; ?> " alt="<?php echo $post_title; ?> "> </a> </div>
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { $metadata = array(); $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false; $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false; global $post; ?> <div class="widget-content"> <ul class="list-unstyled"> <?php $is_first = true; while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if ($is_first) { $is_first = false; ?> <li <?php post_class('style-1'); ?> > <div class="item clearfix"> <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_02'); ?> <a href="<?php echo $post_url; ?> " class="pull-left"> <img src="<?php echo $image_croped; ?> " alt=""> </a> <?php } ?> <div class="item-right"> <?php if ('true' != $instance['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ($metadata['date'] || $metadata['comments']) { ?> <ul class="kp-meta-post list-inline"> <?php $is_metadata_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_metadata_first ? 'metadata-first' : ''; $is_metadata_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; case 'comments': ?> <li class="<?php echo $class; ?> "><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> <?php break; } } } ?> </ul> <?php } ?> <?php if ('true' != $instance['is_hide_excerpt']) { if ((int) $instance['excerpt_character_limit'] > 0) { $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']); echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : ''; } else { the_excerpt(); } } ?> <?php if ('true' != $instance['is_hide_readmore']) { ?> <a class="read-more" href="<?php echo $post_url; ?> "><?php _e('Read more', kopa_get_domain()); ?> </a> <?php } ?> </div> </div> </li> <?php } else { ?> <li> <div class="item clearfix"> <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_00'); ?> <a href="<?php echo $post_url; ?> " class="pull-left"> <img src="<?php echo $image_croped; ?> " alt=""> </a> <?php } ?> <div class="item-right"> <?php if ('true' != $instance['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ($metadata['date'] || $metadata['comments']) { ?> <ul class="kp-meta-post list-inline"> <?php $is_metadata_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_metadata_first ? 'metadata-first' : ''; $is_metadata_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; break; } } } ?> </ul> <?php } ?> </div> </div> </li> <?php } } ?> </ul> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $instance['posts_per_page'] = 4; $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { ?> <div class="widget-content container clearfix"> <div class="owl-slider-col-left pull-left"> <?php $is_first = true; $loop_index = 0; while ($posts->have_posts()) { $posts->the_post(); if (has_post_thumbnail()) { $classes = array('owl-slider-navigation-post-title'); if ($is_first) { $classes[] = 'active'; $classes[] = 'first'; $is_first = false; } ?> <p class="<?php echo implode(' ', $classes); ?> " data-index="<?php echo $loop_index; ?> "> <?php echo get_the_title(); ?> </p> <?php $loop_index++; } } ?> </div> <div class="owl-slider-col-center pull-left"> <div class="owl-carousel" data-transition="<?php echo $instance['transition_type']; ?> "> <?php $is_first = true; global $post; while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); $post_format = get_post_format(); if (has_post_thumbnail()) { $classes = array('owl-slider-single-slide'); if ($is_first) { $classes[] = 'active'; $classes[] = 'first'; $classes[] = 'synced'; $is_first = false; } $image_croped = KopaImage::get_post_image_src($post_id, 'size_11'); ?> <div class="<?php echo implode(' ', $classes); ?> "> <?php if ('video' == $post_format) { $video = KopaUtil::get_video($post->post_content, array('youtube', 'vimeo')); if ($video) { $url = ''; if ('youtube' == $video['type']) { $url = 'http://www.youtube.com/watch?v=' . $video['id']; } else { if ('vimeo' == $video['type']) { $url = 'https://vimeo.com/' . $video['id']; } } printf('<a class="kss-icon kss-icon-play" href="%s"><span class="fa fa-play"></span></a>', $url); } } ?> <img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "> <a href="<?php echo $post_url; ?> " title="<?php echo $post_title; ?> "><?php echo $post_title; ?> </a> </div> <?php } } ?> </div> </div> <div class="owl-slider-col-right pull-left"> <div class="owl-carousel"> <?php $is_first = true; while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); $post_format = get_post_format(); if (has_post_thumbnail()) { $classes = array('owl-slider-single-slide-detail'); if ($is_first) { $classes[] = 'first'; $classes[] = 'synced'; $is_first = false; } ?> <div class="<?php echo implode(' ', $classes); ?> "> <span class="kopa-icon-post-format"><?php echo KopaIcon::getIconPostFormat($post_format, 'span'); ?> </span> <?php if ('true' != $instance['is_hide_created_date']) { ?> <span class="kopa-date"><?php echo get_the_date('M, j'); ?> <br/><?php echo get_the_date('Y'); ?> </span> <?php } ?> <?php if ('true' != $instance['is_hide_views'] || 'true' != $instance['is_hide_comments'] || 'true' != $instance['is_hide_views']) { ?> <ul class="kopa-metadata"> <?php if ('true' != $instance['is_hide_comments']) { ?> <li class="metadata-first"><i class="fa fa-comment"></i><span><?php echo KopaUtil::get_comments($post_id, true); ?> </span></li> <?php } ?> <?php if ('true' != $instance['is_hide_views']) { ?> <li><?php echo KopaIcon::getIconView(); ?> <span><?php echo KopaUtil::get_views($post_id, false); ?> </span></li> <?php } ?> <?php if ('true' != $instance['is_hide_likes']) { ?> <li class="metadata-last"><?php echo KopaIcon::getIconLike(); ?> <span><?php echo KopaUtil::get_likes($post_id, false); ?> </span></li> <?php } ?> </ul> <?php } ?> </div> <?php } } ?> </div> </div> </div> <?php } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { global $post; $metadata = array(); $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false; $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false; $metadata['views'] = 'true' != $instance['is_hide_views'] ? true : false; $metadata['likes'] = 'true' != $instance['is_hide_likes'] ? true : false; ?> <div class="widget-content"> <div class="owl-carousel"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_05'); ?> <div <?php post_class('item'); ?> > <a href="<?php echo $post_url; ?> "><img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "></a> <div class="kp-caption"> <?php if ('true' != $instance['is_hide_title']) { ?> <h3 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h3> <?php } ?> </div> <?php if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) { ?> <footer> <ul class="kp-meta-post list-inline"> <?php $is_metadata_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_metadata_first ? 'metadata-first' : ''; $is_metadata_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; case 'comments': ?> <li class="<?php echo $class; ?> "><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> <?php break; case 'views': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true)); break; case 'likes': printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true)); break; } } } ?> </ul> </footer> <?php } ?> </div> <?php } } ?> </div> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { global $post; ?> <div class="widget-content"> <div class="owl-carousel"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_03'); ?> <div <?php post_class('item'); ?> > <a href="<?php echo $post_url; ?> "><img src="<?php echo $image_croped; ?> " alt="" /> <div class="mask"></div> <div class="mask-2"></div> </a> <div class="kp-caption"> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> </div> </div> <?php } } ?> </div> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { ?> <div class="widget widget-big-carousel"> <div class="widget-content clearfix"> <div class="owl-carousel"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if (has_post_thumbnail()) { $classes = array('item'); $image_croped = KopaImage::get_post_image_src($post_id, 'size_12'); ?> <div <?php post_class($classes); ?> > <a href="<?php echo $post_url; ?> "> <img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "> </a> <div class="post-content"> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <a href="<?php echo $post_url; ?> " class="kopa-readmore"><?php _e('read more', kopa_get_domain()); ?> </a> </div> <div class="mask"></div> </div> <?php } } ?> </div> </div> </div> <?php } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { global $post; $max = (int) $instance['posts_per_page']; $limit_carousel = $max >= 3 ? $posts->post_count - 2 : -1; $loop_index = 0; $metadata = array(); $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false; $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false; $metadata['views'] = 'true' != $instance['is_hide_views'] ? true : false; $metadata['likes'] = 'true' != $instance['is_hide_likes'] ? true : false; ?> <div class="widget-content clearfix"> <div class="owl-carousel pull-left"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if (-1 != $limit_carousel && $limit_carousel == $loop_index) { break; } else { $loop_index++; } ?> <div <?php post_class('item'); ?> > <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_04'); ?> <a href="<?php echo $post_url; ?> "><img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "/></a> <?php } ?> <?php if ('true' != $instance['is_hide_title'] || 'true' != $instance['is_hide_excerpt']) { ?> <div class="kp-caption"> <?php if ('true' != $instance['is_hide_title']) { ?> <?php $h4_class = 'true' != $instance['is_hide_excerpt'] ? '' : 'hide_excerpt'; ?> <h4 class="post-title <?php echo $h4_class; ?> "><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ('true' != $instance['is_hide_excerpt']) { if ((int) $instance['excerpt_character_limit'] > 0) { $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']); echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : ''; } else { the_excerpt(); } } ?> </div> <?php } ?> <?php if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) { ?> <footer> <ul class="kp-meta-post list-inline"> <?php $is_metadata_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_metadata_first ? 'metadata-first' : ''; $is_metadata_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; case 'comments': ?> <li class="<?php echo $class; ?> "><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> <?php break; case 'views': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true)); break; case 'likes': printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true)); break; } } } ?> </ul> </footer> <?php } ?> </div> <?php } wp_reset_postdata(); ?> </div> <?php if (-1 != $limit_carousel) { ?> <ul class="list-content pull-left list-unstyled"> <?php $sub_posts = new WP_Query($query); $sub_loop_index = 0; while ($sub_posts->have_posts()) { $sub_posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if ($sub_loop_index >= $limit_carousel) { ?> <li> <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_02'); ?> <a href="<?php echo $post_url; ?> "><img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> "/></a> <?php } ?> <?php if ('true' != $instance['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) { ?> <footer> <ul class="kp-meta-post list-inline"> <?php $is_metadata_first = true; foreach ($metadata as $key => $val) { if ($val) { $class = $is_metadata_first ? 'metadata-first' : ''; $is_metadata_first = false; switch ($key) { case 'date': printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date()); break; case 'comments': ?> <li class="<?php echo $class; ?> "><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> <?php break; } } } ?> </ul> </footer> <?php } ?> </li> <?php } $sub_loop_index++; } wp_reset_postdata(); ?> </ul> <?php } ?> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { global $post; ?> <div class="widget-content"> <ul class="list-unstyled"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); ?> <li <?php post_class('clearfix'); ?> > <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_00'); ?> <a href="<?php echo $post_url; ?> " class="pull-left"> <img src="<?php echo $image_croped; ?> " alt=""> </a> <?php } ?> <div class="item-right"> <?php if ('true' != $instance['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ('true' != $instance['is_hide_created_date']) { ?> <span class="kp-meta-post"><?php echo get_the_date(); ?> </span> <?php } ?> </div> </li> <?php } ?> </ul> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } wp_reset_postdata(); echo $after_widget; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $query = $this->build_query($instance); $posts = new WP_Query($query); if ($posts->have_posts()) { global $post; ?> <div class="widget-content"> <div class="container"> <ul class="list-unstyled"> <?php while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); if (has_post_thumbnail()) { ?> <li> <div <?php post_class('item'); ?> > <?php $image_croped = KopaImage::get_post_image_src($post_id, 'size_01'); ?> <a href="<?php echo $post_url; ?> "> <img src="<?php echo $image_croped; ?> " alt=""> <div class="mask"></div> <div class="mask-2"></div> </a> <div class="kp-caption"> <?php if ('true' != $instance['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if ('true' != $instance['is_hide_created_date']) { ?> <span class="kp-meta-post date updated"><?php echo get_the_date(); ?> </span> <?php } ?> <?php if ('true' != $instance['is_hide_excerpt']) { if ((int) $instance['excerpt_character_limit'] > 0) { $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']); echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : ''; } else { the_excerpt(); } } ?> </div> </div> </li> <?php } } ?> </ul> </div> </div> <?php } else { _e('Posts not found. Pleae config this widget again!', kopa_get_domain()); } wp_reset_postdata(); echo $after_widget; }
/** * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 */ function kopa_get_related_posts() { if (is_single()) { $get_by = get_option('post_related_posts_get_by', 'post_tag'); $limit = (int) KopaOptions::get_option('post_related_posts_limit', 4); if ($limit > 0) { global $post; $taxs = array(); if ('category' == $get_by) { $cats = get_the_category($post->ID); if ($cats) { $ids = array(); foreach ($cats as $cat) { $ids[] = $cat->term_id; } $taxs[] = array('taxonomy' => 'category', 'field' => 'id', 'terms' => $ids); } } else { $tags = get_the_tags($post->ID); if ($tags) { $ids = array(); foreach ($tags as $tag) { $ids[] = $tag->term_id; } $taxs[] = array('taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $ids); } } if ($taxs) { $related_args = array('tax_query' => $taxs, 'post__not_in' => array($post->ID), 'posts_per_page' => $limit); $related_posts = new WP_Query($related_args); if ($related_posts->have_posts()) { ?> <div class="related-article"> <h3 class="widget-title"><span><span><span><?php _e('Related articles', kopa_get_domain()); ?> </span></span></span></h3> <div class="widget-content"> <div class="owl-carousel owl-carousel-related"> <?php while ($related_posts->have_posts()) { $related_posts->the_post(); $post_id = get_the_ID(); $post_url = get_permalink(); $post_title = get_the_title(); ?> <div <?php post_class('item'); ?> > <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_08'); ?> <a href="<?php echo $post_url; ?> "><img src="<?php echo $image_croped; ?> " alt="<?php echo $post_title; ?> " /></a> <?php } ?> <div class="kp-caption"> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <ul class="kp-meta-post list-inline"> <li><?php echo KopaIcon::getIconDatetime(); ?> <span><?php echo get_the_date(); ?> </span></li> <li><?php echo KopaIcon::getIconComment(); ?> <span><?php comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </span></li> </ul> <span class="kp-meta-post"><?php echo get_the_date(); ?> </span> </div> </div> <?php } ?> </div> </div> </div> <?php } wp_reset_postdata(); } } } }
public static function get_html($query, $params, $paged = 1, $orderby = 'date') { global $post; $query['paged'] = (int) $paged; $posts = new WP_Query($query); while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $post_title = get_the_title(); $post_url = get_permalink(); $post_format = get_post_format(); ?> <div class="item"> <?php if (has_post_thumbnail()) { $image_croped = KopaImage::get_post_image_src($post_id, 'size_07'); ?> <figure> <a href="<?php echo $post_url; ?> " class="pull-left"> <img src="<?php echo $image_croped; ?> " alt=""> <span><?php echo KopaIcon::getIconPostFormat($post_format); ?> </span> </a> </figure> <?php } ?> <div class="item-content"> <?php if (!$params['is_hide_title']) { ?> <h4 class="post-title"><a href="<?php echo $post_url; ?> "><?php echo $post_title; ?> </a></h4> <?php } ?> <?php if (!$params['is_hide_excerpt']) { if ((int) $params['excerpt_character_limit'] > 0) { $excerpt = KopaUtil::substr($post->post_content, (int) $params['excerpt_character_limit']); echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : ''; } else { the_excerpt(); } } ?> </div> <ul class="kp-meta-post bottom list-inline"> <li class="metadata-first"><?php echo KopaIcon::getIconDatetime(); ?> <span><?php echo get_the_date(); ?> </span></li> <?php switch ($orderby) { case 'views': printf('<li>%s<span>%s</span></li>', KopaIcon::getIconView(), KopaUtil::get_views($post_id, true)); break; case 'likes': printf('<li>%s</li>', KopaUtil::kopa_get_like_button($post_id, true)); break; default: ?> <li><?php echo KopaIcon::getIconComment(); comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain())); ?> </li> <?php break; } ?> </ul> </div> <?php } wp_reset_postdata(); }