<?php /** * 首页模板 - 足球比分资讯视频网站 * Template Name: 足球首页 */ get_header(); ?> <div class="football-site-wrapper"> <!-- 顶部实时比分滚动条 --> <div class="live-scores-ticker"> <div class="container"> <div class="ticker-label">⚽ 实时比分</div> <div class="ticker-content"> <?php echo do_shortcode('[proscores list="live"]'); ?> </div> </div> </div> <!-- 主视觉区:焦点比赛/视频 --> <section class="featured-section"> <div class="container"> <div class="featured-grid"> <!-- 左侧焦点比赛 --> <div class="featured-match"> <h2 class="section-title">焦点战役</h2> <?php // 显示今日焦点比赛(可通过后台设置) $featured_match = new WP_Query(array( 'post_type' => 'sp_event', 'posts_per_page' => 1, 'meta_key' => 'sp_featured', 'meta_value' => '1' )); if($featured_match->have_posts()): while($featured_match->have_posts()): $featured_match->the_post(); ?> <div class="featured-match-card"> <?php if(has_post_thumbnail()): ?> <div class="match-video-thumb"> <?php the_post_thumbnail('large'); ?> <span class="play-icon">▶</span> </div> <?php endif; ?> <div class="match-info"> <h3><?php the_title(); ?></h3> <div class="match-meta"> <span class="match-time"><?php echo get_post_meta(get_the_ID(), 'sp_date', true); ?></span> <span class="match-competition"><?php echo get_the_terms(get_the_ID(), 'sp_league')[0]->name ?? ''; ?></span> </div> <a href="<?php the_permalink(); ?>" class="btn-view">查看详情</a> </div> </div> <?php endwhile; wp_reset_postdata(); else: // 默认显示短代码比分 echo do_shortcode('[proscores list="live"]'); endif; ?> </div> <!-- 右侧视频精选 --> <div class="featured-videos"> <h2 class="section-title">精选视频</h2> <div class="video-list"> <?php $videos = new WP_Query(array( 'post_type' => 'post', 'category_name' => 'video', 'posts_per_page' => 3 )); if($videos->have_posts()): while($videos->have_posts()): $videos->the_post(); ?> <div class="video-item"> <a href="<?php the_permalink(); ?>"> <?php if(has_post_thumbnail()): ?> <div class="video-thumb"> <?php the_post_thumbnail('thumbnail'); ?> <span class="play-small">▶</span> </div> <?php endif; ?> <div class="video-title"><?php the_title(); ?></div> </a> </div> <?php endwhile; wp_reset_postdata(); endif; ?> </div> </div> </div> </div> </section> <!-- 今日赛程/比分板 --> <section class="today-matches"> <div class="container"> <h2 class="section-title">📅 今日赛程</h2> <div class="matches-table"> <?php echo do_shortcode('[proscores list="today"]'); ?> </div> </div> </section> <!-- 五大联赛积分榜 --> <section class="leagues-standings"> <div class="container"> <h2 class="section-title">🏆 联赛积分榜</h2> <div class="standings-tabs"> <ul class="tab-nav"> <li class="active"><a href="#epl">英超</a></li> <li><a href="#laliga">西甲</a></li> <li><a href="#seriea">意甲</a></li> <li><a href="#bundesliga">德甲</a></li> <li><a href="#ligue1">法甲</a></li> </ul> <div class="tab-content"> <div id="epl" class="tab-pane active"> <?php echo do_shortcode('[prostandings path="/a/50/league/england-premier-league/standings" compact="0" logos="1"]'); ?> </div> <div id="laliga" class="tab-pane"> <?php echo do_shortcode('[prostandings path="/a/23/league/spain-la-liga/standings" compact="0" logos="1"]'); ?> </div> <div id="seriea" class="tab-pane"> <?php echo do_shortcode('[prostandings path="/a/71/league/italy-serie-a/standings" compact="0" logos="1"]'); ?> </div> <div id="bundesliga" class="tab-pane"> <?php echo do_shortcode('[prostandings path="/a/78/league/germany-bundesliga/standings" compact="0" logos="1"]'); ?> </div> <div id="ligue1" class="tab-pane"> <?php echo do_shortcode('[prostandings path="/a/331/league/france-ligue-1/standings" compact="0" logos="1"]'); ?> </div> </div> </div> </div> </section> <!-- 最新资讯和视频混合区 --> <section class="latest-content"> <div class="container"> <div class="content-grid"> <!-- 最新新闻 --> <div class="latest-news"> <h2 class="section-title">📰 最新资讯</h2> <div class="news-list"> <?php $news = new WP_Query(array( 'post_type' => 'post', 'category_name' => 'news', 'posts_per_page' => 5 )); if($news->have_posts()): while($news->have_posts()): $news->the_post(); ?> <article class="news-item"> <?php if(has_post_thumbnail()): ?> <div class="news-thumb"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a> </div> <?php endif; ?> <div class="news-content"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <div class="news-meta"> <span class="date"><?php echo get_the_date(); ?></span> <span class="comments"><?php comments_number('0', '1', '%'); ?>评论</span> </div> </div> </article> <?php endwhile; wp_reset_postdata(); endif; ?> </div> <a href="<?php echo get_category_link(get_cat_ID('news')); ?>" class="btn-more">更多资讯 →</a> </div> <!-- 最新视频 --> <div class="latest-videos"> <h2 class="section-title">🎥 最新视频</h2> <div class="videos-grid"> <?php $videos = new WP_Query(array( 'post_type' => 'post', 'category_name' => 'video', 'posts_per_page' => 4 )); if($videos->have_posts()): while($videos->have_posts()): $videos->the_post(); ?> <div class="video-card"> <a href="<?php the_permalink(); ?>"> <?php if(has_post_thumbnail()): ?> <div class="video-thumb"> <?php the_post_thumbnail('medium'); ?> <span class="play-overlay">▶</span> </div> <?php endif; ?> <h4><?php the_title(); ?></h4> </a> </div> <?php endwhile; wp_reset_postdata(); endif; ?> </div> <a href="<?php echo get_category_link(get_cat_ID('video')); ?>" class="btn-more">更多视频 →</a> </div> </div> </div> </section> <!-- 欧冠/欧联专区 --> <section class="europe-section"> <div class="container"> <h2 class="section-title">🇪🇺 欧洲赛场</h2> <div class="europe-grid"> <div class="ucl-block"> <h3>欧冠联赛</h3> <?php echo do_shortcode('[proscores list="league" path="/a/529/league/europe-uefa-european-championship/"]'); ?> </div> <div class="uel-block"> <h3>欧联杯</h3> <?php echo do_shortcode('[proscores list="league" path="/a/307/league/europe-uefa-europa-league/"]'); ?> </div> </div> </div> </section> </div> <style> /* 首页样式 */ .football-site-wrapper { font-family: 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; } .container { max-width: 1200px; margin: 0 auto; padding: 0 15px; } /* 实时比分滚动条 */ .live-scores-ticker { background: #1a2c3e; color: white; padding: 8px 0; border-bottom: 2px solid #e44d2e; } .ticker-label { display: inline-block; background: #e44d2e; padding: 2px 12px; border-radius: 4px; font-weight: bold; margin-right: 15px; } .ticker-content { display: inline-block; overflow-x: auto; white-space: nowrap; width: calc(100% - 120px); } /* 焦点区域 */ .featured-section { padding: 30px 0; background: #fff; } .featured-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; } .section-title { font-size: 24px; border-left: 5px solid #e44d2e; padding-left: 15px; margin-bottom: 20px; color: #1a2c3e; } .featured-match-card { position: relative; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.1); } .match-video-thumb { position: relative; height: 300px; } .match-video-thumb img { width: 100%; height: 100%; object-fit: cover; } .play-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(228, 77, 46, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 24px; } .match-info { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; background: linear-gradient(transparent, rgba(0,0,0,0.8)); color: white; } .match-info h3 { font-size: 22px; margin-bottom: 5px; } .btn-view { display: inline-block; margin-top: 10px; padding: 8px 20px; background: #e44d2e; color: white; text-decoration: none; border-radius: 4px; } /* 视频列表 */ .video-list { display: flex; flex-direction: column; gap: 15px; } .video-item a { display: flex; gap: 12px; text-decoration: none; color: #333; } .video-thumb { position: relative; width: 100px; height: 70px; border-radius: 4px; overflow: hidden; } .video-thumb img { width: 100%; height: 100%; object-fit: cover; } .play-small { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 24px; height: 24px; background: rgba(228, 77, 46, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; } /* 今日赛程 */ .today-matches { padding: 30px 0; background: #f9f9f9; } .matches-table { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); } /* 积分榜选项卡 */ .standings-tabs { background: white; border-radius: 8px; padding: 20px; } .tab-nav { display: flex; list-style: none; padding: 0; margin: 0 0 20px 0; border-bottom: 2px solid #e0e0e0; } .tab-nav li { margin-right: 5px; } .tab-nav a { display: block; padding: 10px 20px; text-decoration: none; color: #666; border-radius: 4px 4px 0 0; } .tab-nav li.active a { background: #e44d2e; color: white; } .tab-pane { display: none; } .tab-pane.active { display: block; } /* 最新内容 */ .latest-content { padding: 30px 0; background: #fff; } .content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; } .news-item { display: flex; gap: 15px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #eee; } .news-item:last-child { border-bottom: none; } .news-thumb { width: 80px; height: 80px; border-radius: 4px; overflow: hidden; } .news-thumb img { width: 100%; height: 100%; object-fit: cover; } .news-content h3 { font-size: 16px; margin: 0 0 8px 0; } .news-content h3 a { text-decoration: none; color: #1a2c3e; } .news-meta { font-size: 12px; color: #999; } .news-meta span { margin-right: 10px; } .btn-more { display: inline-block; margin-top: 15px; color: #e44d2e; text-decoration: none; font-weight: bold; } /* 视频网格 */ .videos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; } .video-card { position: relative; } .video-card a { text-decoration: none; color: #333; } .video-card .video-thumb { width: 100%; height: 120px; border-radius: 4px; overflow: hidden; position: relative; } .play-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 36px; height: 36px; background: rgba(228, 77, 46, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 16px; } .video-card h4 { font-size: 14px; margin-top: 8px; line-height: 1.4; } /* 欧洲赛场 */ .europe-section { padding: 30px 0; background: #f0f2f5; } .europe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; } .ucl-block, .uel-block { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); } .ucl-block h3, .uel-block h3 { color: #1a2c3e; border-bottom: 2px solid #e44d2e; padding-bottom: 10px; margin-bottom: 15px; } /* 响应式 */ @media (max-width: 768px) { .featured-grid, .content-grid, .europe-grid { grid-template-columns: 1fr; } .tab-nav { flex-wrap: wrap; } } </style> <?php get_footer(); ?>