faq.php
2.43 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
<?php
function fenix_faq ($atts)
{
$atts = shortcode_atts(
array(
'id' => '',
'title'=>''
),
$atts,
'fenix_faq'
);
$out = ''.
'<!--FAQ-->'.
'<div id="'.$atts['category_name'].'" class="fenix-faq shadow-1"'.(has_post_thumbnail($post->ID)?' style="background-image: url('.get_the_post_thumbnail_url($post->ID, 'full').');"':'').'>'.
'<div class="container">'.
'<h1>'.$atts['title'].'</h1>'.
'<div class="row">'.
'<div class="col-12">'.
'<div class="accordion accordion-flush" id="accordionFlushFAQ">';
$args = array(
'numberposts' => -1,
'category_name' => 'faq',
'post_type' => 'post',
'order' => 'ASC'
);
$posts = get_posts($args);
foreach($posts as $key=>$post)
{
setup_postdata( $post );
$out.= ''.
'<div class="accordion-item bg-custom-5">'.
'<h2 class="accordion-header" id="flush-heading-'.$key.'">'.
'<button class="accordion-button collapsed text-color-1" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapse-'.$key.'" aria-expanded="false" aria-controls="flush-collapse-'.$key.'">'.$post->post_title.'</button>'.
'</h2>'.
'<div id="flush-collapse-'.$key.'" class="accordion-collapse collapse" aria-labelledby="flush-heading-'.$key.'" data-bs-parent="#accordionFlushFAQ">'.
'<div class="accordion-body">'.
$post->post_content.
'</div>'.
'</div>'.
'</div>';
}
wp_reset_postdata();
unset($key, $post, $posts, $args);
$out.= ''.
'</div>'.
'<div class="text-center">'.
'<button class="btn btn-lg btn-style-3 rounded-pill btn-down mb-4" role="button" data-icon="arrow_down"></button>'.
'</div>'.
'</div>'.
'</div>'.
'</div>'.
'</div>';
return $out;
}
add_shortcode('fenix_faq', 'fenix_faq');