example.php
4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
function fenix_example ($atts, $content)
{
$atts = shortcode_atts(
array(
'category_name' => '',
'link' => '#',
'id' => ''
),
$atts,
'fenix_example'
);
$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'.($key===0?' active':'').' col-12 col-md-4 d-md-block me-md-0" data-bs-interval="false">'.
'<div class="card rounded-4 overflow-hidden shadow-block border-0 mb-4">'.
(
has_post_thumbnail($post->ID)?
'<div class="position-relative">'.
'<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="card-img-top" />'.
'<div class="size d-flex rounded-pill text-color-3 position-absolute top-0 bottom-0 start-0 end-0 m-auto align-items-center justify-content-center">'.get_the_post_thumbnail_caption( $post->ID ).' м<sup>2</sup></div>'.
'</div>':
''
).
'<div class="card-body text-center">'.
'<div class="title">'.
'<h5 class="card-title text-color-3 fw-bold">'.$post->post_title.'</h5>'.
(
$post->post_excerpt!=''?
'<h6 class="card-subtitle text-color-3">'.$post->post_excerpt.'</h6>':
''
).
'</div>'.
$post->post_content.
'<a href="'.$atts['link'].'" class="btn btn-lg btn-style-0 rounded-pill">Получить бинес план</a>'.
'</div>'.
'</div>'.
'</div>';
}
wp_reset_postdata();
unset($key, $post, $posts, $args);
$out = ''.
'<!--Примеры эффективных-->'.
'<div id="'.$atts['id'].'" class="container fenix_example '.$atts['category_name'].'">'.
'<div class="row">'.
'<div class="col-12 pt-3 pt-md-5">'.
'<h1>'.esc_html($content).'</h1>'.
'</div>'.
'</div>'.
'<!--карусель-->'.
'<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>';
unset($out_parts);
}
return $out;
}
add_shortcode('fenix_example', 'fenix_example');