File: /www/wwwroot/h3.iyingtaos.cn/wp-content/themes/three-picture/index.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);
foreach ($categories as $index=>$category) {
$active_class = ($index === 0) ? '' : '';
echo '<div class="nav-item"><a class="'.$active_class.'" 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;
$initial_query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 10, // 初始加载的文章数量
));
while ($initial_query->have_posts()) {
$initial_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();
?>
<script>var a=document.querySelector('.nav'); console.log(a)</script>