punkts.php
3.67 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
<?php
function fenix_punkts ($atts, $content)
{
$atts = shortcode_atts(
array(
'category_name' => '',
'title' => '',
'id' => ''
),
$atts,
'fenix_punkts'
);
$out = '';
if ($atts['category_name']!=='')
{
$out_parts = array(
'btns' => '',
'tabs' => ''
);
$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['btns'].= '<button class="nav-link border-top'.($key===0?' active':'').'" id="pills-'.$key.'-tab" data-bs-toggle="pill" data-bs-target="#pills-'.$key.'" type="button" role="tab" aria-controls="pills-'.$key.'" aria-selected="'.($key===0?'true':'false').'">'.((int)$key + 1).'. '.($post->post_excerpt==''?$post->post_title:$post->post_excerpt).'</button>';
$out_parts['tabs'].= ''.
'<div class="tab-pane fade '.($key===0?' show active':'').'" id="pills-'.$key.'" role="tabpanel" aria-labelledby="pills-'.$key.'-tab">'.
'<div class="row flex-md-row-reverse">'.
(
has_post_thumbnail($post->ID)?
'<div class="col-12 col-md-6">'.
'<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="img-fluid rounded-4 mb-2 mb-md-0" />'.
'</div>'.
'<div class="col-12 col-md-6">':
'<div class="col-12">'
).
'<h5 class="text-color-3 mb-3">'.$post->post_title.'</h5>'.
$post->post_content.
'</div>'.
'</div>'.
'</div>';
}
wp_reset_postdata();
unset($key, $post, $posts, $args);
$out = ''.
'<!--6 основных пунктов открытия клиник-->'.
'<div id="'.$atts['id'].'" class="fenix_punkts shadow-sm '.$atts['category_name'].'">'.
'<div class="container">'.
'<div class="row">'.
'<div class="col-12 pt-3 pt-md-5">'.
'<h1>'.$atts['title'].'</h1>'.
'<div class="nav nav-pills mb-3 border-bottom" id="pills-'.$atts['id'].'-tab" role="tablist">'.
$out_parts['btns'].
'</div>'.
'<div class="tab-content p-3" id="pills-'.$atts['id'].'-tabContent">'.
$out_parts['tabs'].
'</div>'.
'</div>'.
'</div>'.
'</div>'.
'</div>';
unset($out_parts);
}
return $out;
}
add_shortcode('fenix_punkts', 'fenix_punkts');