feat: add archive and single templates for all custom post types

This commit is contained in:
2026-04-03 01:17:20 +05:00
parent fe22b37b0e
commit 49709e8cf8
9 changed files with 565 additions and 0 deletions
@@ -0,0 +1,129 @@
<?php
/**
* БИТ.WMS Child Theme — single-case.php
*
* Single (detail) template for the 'case' custom post type.
*
* ACF fields used:
* case_client — text
* case_industry — text
* case_task — wysiwyg
* case_solution — wysiwyg
* case_result — wysiwyg
* case_quote — text
* case_gallery — gallery (array of image arrays)
*
* @package bitwms-child
*/
defined( 'ABSPATH' ) || exit;
get_header();
the_post();
$client = get_field( 'case_client' );
$industry = get_field( 'case_industry' );
$task = get_field( 'case_task' );
$solution = get_field( 'case_solution' );
$result = get_field( 'case_result' );
$quote = get_field( 'case_quote' );
$gallery = get_field( 'case_gallery' );
?>
<main class="single-case">
<div class="container">
<article>
<h1><?php the_title(); ?></h1>
<?php if ( $client || $industry ) : ?>
<div class="single-case__meta">
<?php if ( $client ) : ?>
<span class="single-case__meta-item single-case__client">
<strong><?php esc_html_e( 'Клиент:', 'bitwms-child' ); ?></strong>
<?php echo esc_html( $client ); ?>
</span>
<?php endif; ?>
<?php if ( $industry ) : ?>
<span class="single-case__meta-item single-case__industry">
<strong><?php esc_html_e( 'Отрасль:', 'bitwms-child' ); ?></strong>
<?php echo esc_html( $industry ); ?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $task ) : ?>
<div class="single-case__section single-case__task">
<h2><?php esc_html_e( 'Задача', 'bitwms-child' ); ?></h2>
<?php echo wp_kses_post( $task ); ?>
</div>
<?php endif; ?>
<?php if ( $solution ) : ?>
<div class="single-case__section single-case__solution">
<h2><?php esc_html_e( 'Решение', 'bitwms-child' ); ?></h2>
<?php echo wp_kses_post( $solution ); ?>
</div>
<?php endif; ?>
<?php if ( $result ) : ?>
<div class="single-case__section single-case__result">
<h2><?php esc_html_e( 'Результат', 'bitwms-child' ); ?></h2>
<?php echo wp_kses_post( $result ); ?>
</div>
<?php endif; ?>
<?php if ( $gallery ) : ?>
<div class="single-case__gallery">
<div class="gallery-grid">
<?php foreach ( $gallery as $image ) : ?>
<a href="<?php echo esc_url( $image['url'] ); ?>" target="_blank" rel="noopener">
<img
src="<?php echo esc_url( $image['sizes']['medium_large'] ?? $image['url'] ); ?>"
alt="<?php echo esc_attr( $image['alt'] ); ?>"
width="<?php echo esc_attr( $image['sizes']['medium_large-width'] ?? $image['width'] ); ?>"
height="<?php echo esc_attr( $image['sizes']['medium_large-height'] ?? $image['height'] ); ?>"
>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $quote ) : ?>
<blockquote class="single-case__quote">
<?php echo esc_html( $quote ); ?>
</blockquote>
<?php endif; ?>
<div class="single-case__cta">
<p><?php esc_html_e( 'Хотите такой же результат?', 'bitwms-child' ); ?></p>
<a href="<?php echo esc_url( home_url( '/bit-wms/#demo-form' ) ); ?>" class="btn btn-primary">
<?php esc_html_e( 'Закажите консультацию', 'bitwms-child' ); ?>
</a>
</div>
</article>
<?php
$related = new WP_Query( array(
'post_type' => 'case',
'posts_per_page' => 3,
'orderby' => 'rand',
'post__not_in' => array( get_the_ID() ),
) );
if ( $related->have_posts() ) :
?>
<section class="related-posts">
<h2><?php esc_html_e( 'Другие кейсы', 'bitwms-child' ); ?></h2>
<div class="content-grid">
<?php while ( $related->have_posts() ) : $related->the_post(); ?>
<?php get_template_part( 'templates/content-card' ); ?>
<?php endwhile; ?>
</div>
</section>
<?php
wp_reset_postdata();
endif;
?>
</div>
</main>
<?php get_footer();