File: /www/wwwroot/vietktv.vn/wp-content/themes/binhvu/archive.php
<?php get_header();
$post_type = 'post';
$taxonomy = 'category';
$current_term_id = get_queried_object_id();
$term = get_term((int)$current_term_id, $taxonomy); ?>
<?php require_once(TEMPLATEPATH . '/inc/content-main-header.php'); ?>
<div class="block-breakcrumb">
<div class="container">
<?php if ( function_exists('yoast_breadcrumb') ){yoast_breadcrumb('','');} ?>
</div>
</div><!-- end .block-breakcrumb -->
<div class="sub-wrap block-item">
<div class="container">
<div class="primary fright">
<h1 class="archive-head tf">
<?php echo $term->name; ?>
</h1>
<div class="archive-wrap block-item-content-flex">
<?php
$current = isset($_GET['trang']) ? intval($_GET['trang']) : 1;
$record_per_page = 12;
$offset = ( $current - 1 ) * $record_per_page;
$total = ceil(wp_count_posts($post_type)->publish / $record_per_page);
$args = array(
'post_type' => $post_type,
'posts_per_page' => $record_per_page,
'page' => $current,
'offset' => $offset,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $current_term_id,
),
),
);
$tax_query = new WP_Query($args);
if($tax_query->have_posts()): while($tax_query->have_posts()) : $tax_query->the_post(); ?>
<div class="archive-du-an-item home-new-item fleft">
<a class="home-new-item-thumb thumb-cover item-thumbnail" href="<?php the_permalink(); ?>">
<?php if(has_post_thumbnail()){the_post_thumbnail('full'); }else{ echo '<img src="images/thumb/placeholder.png" alt="not avaiable" title="not avaiable"/>'; } ?>
<div class="thumbnail-hoverlay main-color-1-bg"></div>
<div class='thumbnail-hoverlay-icon'><i class="fal fa-search"></i></div>
</a>
<div class="home-new-item-info">
<h2 class="home-new-item-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<div class="home-new-item-date-comment">
<span><i class="far fa-calendar"></i><?php the_time('d/m/Y'); ?></span>
<span><i class="far fa-comments-alt"></i>0 Bình luận</span>
</div>
<div class="home-new-item-des">
<?php echo wp_trim_words(get_the_excerpt(), 25, '...'); ?>
</div>
</div>
</div>
<?php endwhile; wp_reset_postdata(); else: ?>
<p class="empty-content">Bài viết đang cập nhật ...</p>
<?php endif; ?>
<div class="cboth"></div>
</div>
<div class="pagination">
<?php
$big = 999999999;
echo paginate_links(array(
'base' => @add_query_arg('trang', '%#%'),
'format' => '?paged=%#%',
'current' => $current,
'total' => $tax_query->max_num_pages,
'prev_text' => __('«'),
'next_text' => __('»'),
'mid_size' => 5
)); ?>
</div>
</div><!-- end .primary -->
<?php get_sidebar('post'); ?>
<div class="cboth"></div>
</div><!-- end .container -->
</div><!-- end .block-item-->
<?php get_footer(); ?>