full
This commit is contained in:
97
template-parts/trainings-template.php
Normal file
97
template-parts/trainings-template.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*
|
||||
Template Name: Страница тренировок
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
if (!function_exists('get_trainings_for_current_language')) {
|
||||
function get_trainings_for_current_language()
|
||||
{
|
||||
$current_lang = pll_current_language();
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'training',
|
||||
'posts_per_page' => -1,
|
||||
'lang' => $current_lang,
|
||||
'post_status' => 'publish',
|
||||
'sort' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
return get_posts($args);
|
||||
}
|
||||
}
|
||||
|
||||
$trainings = get_trainings_for_current_language();
|
||||
|
||||
// Получаем все поля short_info для каждой тренировки
|
||||
$trainings_data = array();
|
||||
if ($trainings) {
|
||||
foreach ($trainings as $training) {
|
||||
$training_info = array(
|
||||
'post' => $training,
|
||||
'name' => '',
|
||||
'exp' => '',
|
||||
'short_desc' => ''
|
||||
);
|
||||
|
||||
if (have_rows('short_info', $training->ID)) {
|
||||
while (have_rows('short_info', $training->ID)) {
|
||||
the_row();
|
||||
$training_info['name'] = get_sub_field('name');
|
||||
$training_info['exp'] = get_sub_field('exp');
|
||||
$training_info['short_desc'] = get_sub_field('short_desc');
|
||||
}
|
||||
}
|
||||
|
||||
$trainings_data[] = $training_info;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<section class="py-[96px]">
|
||||
<div class="container mx-auto">
|
||||
<?php if ($trainings_data): ?>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-[24px]">
|
||||
<?php foreach ($trainings_data as $training_data): ?>
|
||||
<?php $training = $training_data['post']; ?>
|
||||
<div class="h-[540px] max-w-[312px] group">
|
||||
<div class="flex flex-col bg-[#f8f8f8] relative h-[540px] rounded-[20px] overflow-hidden shadow-[0_2px_32px_0_rgba(16,_15,_15,_0.03)] group-hover:shadow-[0_8px_32px_0_rgba(16,_15,_15,_0.12)] transition-shadow duration-300">
|
||||
<?php $photo_images = get_field('photo', $training->ID); ?>
|
||||
<?php if ($photo_images && !empty($photo_images[0])): ?>
|
||||
<div class="overflow-hidden min-h-[260px]">
|
||||
<img src="<?php echo esc_url($photo_images[0]['url']); ?>"
|
||||
alt="<?php echo esc_attr($photo_images[0]['alt']); ?>"
|
||||
loading="lazy"
|
||||
class="w-full h-full object-cover group-hover:scale-[1.05] transition-transform duration-300"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="flex flex-col gap-[24px] h-full p-[24px]">
|
||||
<?php $name = $training_data['name']; ?>
|
||||
<?php if ($name): ?>
|
||||
<div class="text-[24px] leading-[125%] font-[600]">
|
||||
<?php echo esc_html($name); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $short_desc = $training_data['short_desc']; ?>
|
||||
<?php if ($short_desc): ?>
|
||||
<div class="text-[16px] leading-[145%] font-[500] text-[#222]">
|
||||
<?php echo wp_kses_post($short_desc); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo get_permalink($training->ID); ?>" class="!no-underline mt-auto h-[59px] flex grey-gradient-hover w-full rounded-[90px] px-[12px] text-[18px] font-[600] leading-[195%] text-[#f8f8f8] bg-[0_2px_32px_0_rgba(16,_15,_15,_0.03)] items-center justify-center hover:opacity-90 transition-opacity duration-300">
|
||||
Перейти
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
Reference in New Issue
Block a user