/home/bdqbpbxa/demo-subdomains/sparkskyiv.goodface.com.ua/wp-content/themes/sparks/single.php
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package sparks
*/
get_header();
?>
<?php
global $post;
setup_postdata( $post );
$ID = $post->ID;
?>
<div class="article-wrapper">
<div class="article-container">
<a href="<?php bloginfo('url'); if ('uk' == pll_current_language()): echo '/novini/'; endif; if ('ru' == pll_current_language()): echo '/novosti/'; endif; if ('en' == pll_current_language()): echo '/news/'; endif; ?>" class="back-btn"><svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="5.9px" height="9.5px" viewBox="0 0 5.9 9.5" style="enable-background:new 0 0 5.9 9.5;" xml:space="preserve">
<style type="text/css">
.st0{clip-path:url(#SVGID_2_);fill:none;stroke:#d79660;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
</style>
<g>
<defs>
<rect id="SVGID_1_" width="5.9" height="9.5"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" style="overflow:visible;"/>
</clipPath>
<polyline class="st0" points="5.1,8.8 0.8,4.8 5.1,0.8 "/>
</g>
</svg>
<span><?php if ('uk' == pll_current_language()): echo 'Повернутися назад'; endif; if ('ru' == pll_current_language()): echo 'Вернутся назад'; endif; if ('en' == pll_current_language()): echo 'Go back'; endif; ?></span></a>
<article class="article">
<div class="article-image" style="background-image: url(<?php echo get_the_post_thumbnail_url(); ?>); background-position: 50% 50%; background-repeat: no-repeat; background-size: cover;"></div>
<div class="article-inner">
<div class="article-date"><?php the_field('event_date'); ?></div>
<h1 class="article-title"><?php the_title(); ?></h1>
<?php
$after_header_desc = get_field('after_title_desc');
$after_header_desc=str_ireplace('<p>','',$after_header_desc);
$after_header_desc=str_ireplace('</p>','',$after_header_desc);
?>
<div class="article-desc"><?php echo $after_header_desc; ?></div>
<div class="article-content">
<?php the_content(); ?>
</div>
</div>
</article>
<div class="video-block">
<div class="video-poster">
<img src="<?php the_field('video_cover'); ?>" alt="">
</div>
<?php
$video = get_field('post_video');
preg_match('/src="(.+?)"/', $video, $matches);
if($video) {
?>
<div class="play-video-btn">
<a href="#video-modal" class="play modal-button" data-video="<?php echo $matches[1]; ?>">
<span class="icon">
<svg width="50" height="50" viewBox="0 0 50 50">
<path fill="none" d="M25 1c13.2 0 24 10.8 24 24S38.2 49 25 49 1 38.2 1 25 11.8 1 25 1m0-1C11.2 0 0 11.2 0 25s11.2 25 25 25 25-11.2 25-25S38.8 0 25 0z"></path>
<path class="triangle" fill="#d79660" d="M33.5 25c0 .1-.1.3-.2.4l-12 7c-.1.1-.2.1-.3.1s-.2 0-.2-.1c-.2-.1-.3-.3-.3-.4V18c0-.2.1-.3.3-.4.2-.1.3-.1.5 0l12 7c.2.1.2.3.2.4z"></path>
</svg>
</span>
<span class="icon-text"><?php if ('uk' == pll_current_language()): echo 'Дивитись відео'; endif; if ('ru' == pll_current_language()): echo 'Смотреть видео'; endif; if ('en' == pll_current_language()): echo 'Watch video'; endif; ?></span>
</a>
</div>
<?php } ?>
</div>
<div class="related-news">
<?php $rp = get_field('related_posts');
$rp_arr = array();
foreach($rp as $post) {
$rp_arr[] = $post['related_item']->ID;
}
?>
<div class="related-news-title"><?php if ('uk' == pll_current_language()): echo 'Iншi новини'; endif; if ('ru' == pll_current_language()): echo 'Остальные новости'; endif; if ('en' == pll_current_language()): echo 'Other news'; endif; ?></div>
<div class="news-list">
<?php
// задаем нужные нам критерии выборки данных из БД
if($rp_arr) {
$args = array(
'lang' => pll_current_language(),
'post_type' => 'post',
'posts_per_page' => 5,
'post_in' => array($rp_arr),
'post__not_in' => array($ID)
);
} else {
$args = array(
'lang' => pll_current_language(),
'post_type' => 'post',
'posts_per_page' => 5,
'post__not_in' => array($ID),
);
}
$query = new WP_Query( $args );
// Цикл
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<div class="news-item fade-in">
<div class="news-image">
<a href="<?php the_permalink(); ?>" style="background-image: url(<?php echo get_the_post_thumbnail_url(); ?>); background-position: 50% 50%; background-repeat: no-repeat; background-size: cover;"></a>
</div>
<div class="news-date"><?php the_field('event_date'); ?></div>
<div class="news-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="news-desc"><?php the_excerpt(); ?></div>
<div class="news-details">
<a href="<?php the_permalink(); ?>" class="news-details-link"><?php if ('uk' == pll_current_language()): echo 'Читати повністю'; endif; if ('ru' == pll_current_language()): echo 'Читать полностью'; endif; if ('en' == pll_current_language()): echo 'Read all'; endif; ?></a>
</div>
</div>
<?php
}
} else {
// Постов не найдено
}
/* Возвращаем оригинальные данные поста. Сбрасываем $post. */
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
<?php
get_footer();