Files

92 lines
3.3 KiB
PHP

<?php
/**
* БИТ.WMS Child Theme — single-course.php
*
* Single (detail) template for the 'course' custom post type.
*
* ACF fields used:
* course_program — wysiwyg
* course_duration — text (e.g. "16 часов")
* course_format — text (e.g. "Онлайн")
* course_price — text (e.g. "35 000 ₽")
* course_register_url — url (optional; falls back to demo form)
*
* @package bitwms-child
*/
defined( 'ABSPATH' ) || exit;
get_header();
the_post();
$program = get_field( 'course_program' );
$duration = get_field( 'course_duration' );
$format = get_field( 'course_format' );
$price = get_field( 'course_price' );
$register_url = get_field( 'course_register_url' ) ?: home_url( '/bit-wms/#demo-form' );
?>
<main class="single-course">
<div class="container">
<article>
<h1><?php the_title(); ?></h1>
<div class="single-course__meta">
<?php if ( $duration ) : ?>
<span class="single-course__meta-item">
<strong><?php esc_html_e( 'Продолжительность:', 'bitwms-child' ); ?></strong>
<?php echo esc_html( $duration ); ?>
</span>
<?php endif; ?>
<?php if ( $format ) : ?>
<span class="single-course__meta-item">
<strong><?php esc_html_e( 'Формат:', 'bitwms-child' ); ?></strong>
<?php echo esc_html( $format ); ?>
</span>
<?php endif; ?>
<?php if ( $price ) : ?>
<span class="single-course__meta-item single-course__price">
<strong><?php esc_html_e( 'Стоимость:', 'bitwms-child' ); ?></strong>
<?php echo esc_html( $price ); ?>
</span>
<?php endif; ?>
</div>
<?php if ( $program ) : ?>
<div class="single-course__section">
<h2><?php esc_html_e( 'Программа курса', 'bitwms-child' ); ?></h2>
<?php echo wp_kses_post( $program ); ?>
</div>
<?php endif; ?>
<div class="single-course__cta">
<a href="<?php echo esc_url( $register_url ); ?>" class="btn btn-primary">
<?php esc_html_e( 'Записаться', 'bitwms-child' ); ?>
</a>
</div>
</article>
<?php
$related = new WP_Query( array(
'post_type' => 'course',
'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();