37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
global $wp_query;
|
||
|
|
$large_first_image = $args['large_first_image'] ?? true;
|
||
|
|
$post_count = 0;
|
||
|
|
$query = $args['query'] ?? $wp_query;
|
||
|
|
if ($query->have_posts()) {
|
||
|
|
while ($query->have_posts()) {
|
||
|
|
$post_count++;
|
||
|
|
$query->the_post();
|
||
|
|
get_template_part('content', 'post', ['full_width' => $post_count === 1 && $large_first_image]);
|
||
|
|
if ($post_count === ($large_first_image ? 5 : 4)) {
|
||
|
|
$banners = wp_is_mobile() ? get_field('banner_between_posts_mobile', 'option') : get_field('banner_between_posts', 'option');
|
||
|
|
if($banners){
|
||
|
|
$rand_keys = array_rand($banners, 1);
|
||
|
|
if (isset($banners[$rand_keys]) && !empty($banners[$rand_keys]['image_banner'])) {
|
||
|
|
echo '<a href="' . $banners[$rand_keys]['link'] . '"><div class="banner-middle">
|
||
|
|
<img src="' . $banners[$rand_keys]["image_banner"]["url"] . '" alt=""></a></div>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
wp_reset_postdata();
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
|
||
|
|
<style>
|
||
|
|
.banner-middle img {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.banner-middle {
|
||
|
|
overflow: hidden;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
}
|
||
|
|
</style>
|