<?php function fenix_uchastie ($atts, $content) { $atts = shortcode_atts( array( 'category_name' => '', 'id' => '' ), $atts, 'fenix_uchastie' ); $out = ''; if ($atts['category_name']!=='') { $out_parts = array( 'slides' => '' ); $args = array( 'numberposts' => -1, 'category_name' => $atts['category_name'], 'post_type' => 'post', 'order' => 'ASC' ); $posts = get_posts($args); foreach($posts as $key=>$post) { setup_postdata( $post ); $out_parts['slides'].= '<div class="carousel-item col-12 col-md-6 d-md-block me-md-0'.($key===0?' active':'').'">'. $post->post_content. '</div>'; } wp_reset_postdata(); unset($key, $post, $posts, $args); $out = ''. '<!--Активно участвуем в образовательной -->'. '<div id="'.$atts['id'].'" class="container fenix_uchastie '.$atts['category_name'].'">'. '<div class="row">'. '<div class="col-12 pt-3 pt-md-5">'. '<h1>'.$atts['title'].'</h1>'. $content. '<!--карусель-->'. '<div id="slider-'.$atts['id'].'" class="carousel slide" data-bs-interval="false" data-ride="carousel" data-pause="hover">'. '<div class="carousel-inner row m-auto">'. $out_parts['slides']. '</div>'. '<button class="carousel-control-prev d-flex d-md-none justify-content-center rounded-pill bg-color-7 text-color-6" type="button" data-bs-target="#slider-'.$atts['id'].'" data-bs-slide="prev" data-icon="arrow_left"></button>'. '<button class="carousel-control-next d-flex d-md-none justify-content-center rounded-pill bg-color-7 text-color-6" type="button" data-bs-target="#slider-'.$atts['id'].'" data-bs-slide="next" data-icon="arrow_right"></button>'. '</div>'. '<div class="text-center pt-4 d-none">'. '<a href="#" class="btn btn-lg btn-style-0 rounded-pill">Больше</a>'. '</div>'. '</div>'. '</div>'. '</div>'; unset($out_parts); } return $out; } add_shortcode('fenix_uchastie', 'fenix_uchastie');