Files
car-t-t/template-parts/home/service-teaser.php
T
zhs123 8a2890f8b4 refactor: 多页面门店重构 — CPT + 页面模板 + README 更新
- CPT: service(服务项目) + case(案例作品集) + case_type 分类
- 页面: 关于门店/常见问题/预约联系 + archive/single 模板
- 首页精简为 hero+trust+service-teaser+case-teaser+cta
- 主题激活自动迁移 Customizer 产品数据为 service 文章
- 预约表单: nonce+honeypot+rate-limit, URL 参数预填服务
- 联系页: 门店地址/电话/营业时间/百度地图导航
- Customizer 面板改为门店语境(13 板块)
- header CTA 改为预约, helpers 更新为门店口径
- README.md 全面更新为门店多页面架构文档
2026-07-24 15:37:40 +08:00

49 lines
2.0 KiB
PHP

<?php
/** Service teaser on the homepage. @package Fragrance_Trade */
$service_query = new WP_Query(
array(
'post_type' => 'service',
'posts_per_page' => 6,
'post_status' => 'publish',
)
);
if ( ! $service_query->have_posts() ) {
return;
}
?>
<section id="services" class="b2b-section services-section" style="padding-bottom: 5rem;">
<div class="container">
<div class="section-heading text-center mx-auto">
<p class="section-eyebrow"><?php esc_html_e( '服务项目', 'fragrance-trade' ); ?></p>
<h2><?php esc_html_e( '为您的爱车提供的贴膜服务', 'fragrance-trade' ); ?></h2>
</div>
<div class="capability-grid mt-5">
<?php
$count = 1;
while ( $service_query->have_posts() ) :
$service_query->the_post();
$image = get_post_meta( get_the_ID(), '_service_image', true );
$fallback = 'products/placeholder-0' . ( $count < 10 ? $count : 1 ) . '.svg';
$img = $image ? $image : fragrance_trade_asset_uri( $fallback );
?>
<article class="capability-card">
<div class="capability-image"><a href="<?php the_permalink(); ?>"><img src="<?php echo esc_url( $img ); ?>" alt="<?php the_title_attribute(); ?>" class="img-fluid" loading="lazy" decoding="async"></a></div>
<div class="capability-body">
<p class="capability-label"><?php esc_html_e( '贴膜服务', 'fragrance-trade' ); ?></p>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo esc_html( get_the_excerpt() ); ?></p>
<a href="<?php echo esc_url( home_url( '/contact/?service=' . rawurlencode( get_the_title() ) ) ); ?>" class="btn btn-b2b-outline"><?php esc_html_e( '预约这项服务', 'fragrance-trade' ); ?></a>
</div>
</article>
<?php
$count++;
endwhile;
wp_reset_postdata();
?>
</div>
<div class="text-center mt-5">
<a href="<?php echo esc_url( home_url( '/services/' ) ); ?>" class="btn btn-b2b-primary"><?php esc_html_e( '查看全部服务项目', 'fragrance-trade' ); ?></a>
</div>
</div>
</section>