<!doctype html>
<html>
<?php include 'head.php'; ?>
<body>
<?php
/*Template Name: Custom Aboutus*/
get_header();
?>
<div class="ny_ban"><img src="/wp-content/uploads/2024/03/2019072513575281.jpg"></div>

<div class="ny_main w1200">
	<div class="l">
		<div class="box">
    <div class="tit">走进箭冠</div>
    <div class="bor">
        <ul class="lm">
            <?php
            // 获取当前子分类
            $cat_id = $_REQUEST['fid'] ?? 18;
            // 输出目录
            echo get_slider_submenus('about',3,$cat_id)
            ?>
        </ul>
    </div>
</div>		
<?php include 'concat.php'; ?>	
</div>
	<div class="r">
        <div class="tit">
			<div class="lj">您当前位置 :<a href="/index">首页</a> > <a href="/about">走进箭冠</a> > <span><?php echo get_cat_name($cat_id) ?></span></div>
			<span><?php echo get_cat_name($cat_id) ?></span>
		</div>
        <div class="con">
        <?php
            if($cat_id != 24){
                 // 获取该分类下的第一篇文章
                 $args = array(
                    'cat' => $cat_id, // 分类ID
                    'posts_per_page' => 1, // 每页显示的文章数量
                    'orderby' => 'date', // 按日期排序
                    'order' => 'ASC', // 升序
                );

                $cur_post = get_posts($args);
                
                if ($cur_post) {
                    $content = $cur_post[0]->post_content; // 文章内容
                    echo $content;
                } else {
                    echo '文章不存在';
                }

                // 释放查询结果
                wp_reset_postdata();
            }

             
            // 假设你已经在WordPress环境中,并且有分类ID $category_id
            $category_id = $cat_id; // 替换为你的分类ID
            
            // 获取分页参数
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            
            // 查询参数
            $args = array(
                'cat' => $category_id, // 分类ID
                'posts_per_page' => 9, // 每页显示的文章数量
                'paged' => $paged
            );
            
            // 查询文章
            $query = new WP_Query($args);
            
            if ($query->have_posts()) {
                echo '<div class="ny_product"><ul>';
                while ($query->have_posts()) {
                    $query->the_post();
                    // 在这里编写你的文章列表
                    $post_id = get_the_ID(); // 获取文章ID
                    $excerpt = get_the_excerpt(); // 获取摘要
                    if ( mb_strlen( $excerpt ) > 90 ) { // 如果字数超过200字
                        $excerpt = mb_substr( $excerpt, 0, 90 ); // 截取前200个字符
                        $excerpt .= '...'; // 添加省略号
                    }
                    // 门店展示
                    if($cat_id == 24){   
            ?>
                <li>
                    <div>
                        <?php
                        if(has_post_thumbnail()){
                            // 获取特色图片的ID
                            $thumbnail_id = get_post_thumbnail_id();
                            // 获取特色图片的URL
                            $thumbnail_url = wp_get_attachment_url( $thumbnail_id );
                            
                        ?>
                            <a href="#"><img src="<?php echo $thumbnail_url ?>" width="100%"></a>
                        <?php
                            }
                        ?>
                    </div>
                    <h3><a href="#"><?php the_title(); ?></a></h3>
                    <p><?php echo $excerpt; ?></p>
                </li>
        <?php
                 }     
             }
                echo '</ul></div>';
                // 分页导航
                lingfeng_pagenavi();
            } else {
                // 没有找到文章的提示
                echo '没有找到文章。';
            }
            
            // 重置WordPress查询
            wp_reset_postdata();
        ?>
        </div>
    </div>
</div>
<style>
    .swiper-wrapper{height:auto;}
    .ny_product>ul li h3{text-align:center;}
    .ny_product>ul li div{padding:5px;overflow: hidden;}
    .ny_product>ul li div a{display:flex;height:100%;width:100%;align-items: center;justify-content: center;}
</style>
<?php get_footer(); ?>

</body>
</html>