File: /www/wwwroot/h3.iyingtaos.cn/wp-content/themes/three-picture/category.php
<?php
get_header();//获取头部部分
$mulu=get_template_directory_uri();
?>
<link rel="stylesheet" href="<?php echo $mulu.'\\'; ?>\lunbo.css">
</head>
<main class="container">
<div class="main-box">
<div class="header"><a style="text-decoration: none;
color: white;" href="<?php echo esc_url(home_url('/'))?>"><?php bloginfo(); ?></a></div>
<div class="nav">
<?php
$args=array(
'orderby' => 'count',
'hide_empty' => true, //隐藏不带文章的分类
'order' => 'DESC'
);
$categories = get_categories($args);
$current_category = get_queried_object();
foreach ($categories as $index=>$category) {
$is_active = ($current_category && $category->term_id === $current_category->term_id) ? 'active' : '';
echo '<div class="nav-item"><a class="'.$is_active.'" href="' . esc_url(get_category_link($category->term_id)) . '">' . esc_html($category->name) . '</a></div>';
}
$fenlei=single_cat_title('',false);
?>
</div>
<?php get_template_part('templates/xinxiliu'); ?>
<?php
$counter=0;
$query_args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'cat' => $current_category->term_id,
);
$query = new WP_Query($query_args);
while ($query->have_posts()) {
$query->the_post();
$lianjie=get_permalink();
$counter++;
if ($counter < 4) {
if ($counter == 1) {
echo ' <div class="lb">
<div class="swiper-container">
<div class="swiper-wrapper">';
}
$thumbnail_image_url = wp_get_attachment_image_url(get_post_thumbnail_id($post->ID), 'thumbnail');
echo '
<div class="swiper-slide" data-hash="slide' . $counter . '"><a href="'.$lianjie.'"><img src="'.$thumbnail_image_url.'"></a>
<div class="lb-title"><a>'.get_the_title().'</a></div></div>
';
if ($counter == 3) {
echo '
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
<!-- Add Arrows -->
</div>
</div>
';
get_template_part('templates/xinxiliu');
}
}else{
get_template_part('templates/lists');
get_template_part('templates/xinxiliu');
}
}wp_reset_postdata();
?>
</div><?php get_template_part('templates/loading'); ?>
</main>
<div class="loading-indicator" style="display:none; text-align:center;">
<p>正在加载...</p>
</div>
<?php
get_footer();
?>