File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/template/module-page/theme-faq.php
<?php
/**
* Template: 时间轴
* @Author: 大胡子
* @Email: dahuzi@xintheme.com
* @Link: www.xintheme.com
* @Date: 2023-08-01 07:27:28
* @Last Modified by: dahuzi
* @Last Modified time: 2024-11-15 20:25:52
*/
if(is_array($module_content)){?>
<div class="section"<?php if( !empty($module_setting['module_bg']) ){ echo ' style="background:url('.$module_setting['module_bg'].') no-repeat center 0 / cover;"';}?>>
<div class="container">
<?php
if( !empty($module_setting['title_display']) ){?>
<div class="section-title <?php echo $wow_style;?><?php if( !empty($module_setting['module_bg']) ){ echo ' text-colour-white';}?>">
<?php
if( !empty($module_title) ){
echo '<strong>'.$module_title.'</strong>';
}
if( !empty($module_desc) ){
echo '<p>'.$module_desc.'</p>';
}
?>
</div>
<?php }?>
<div class="list-five <?php if( !empty($module_setting['contact_style']) ){ echo $module_setting['contact_style'];}?>">
<?php
if (!empty($module_content['faq_id'])) {
// 获取指定 ID 的文章
$faqArray = array(
'post_type' => 'faq',
'post__in' => $module_content['faq_id'],
'orderby' => 'post__in',
);
$faq_query = wpjam_query($faqArray);
if ($faq_query->have_posts()) {
// 检查 $module_setting['contact_style'] 是否为 'style_1'
if ($module_setting['contact_style'] == 'style_1') {
// 获取文章总数
$total_posts = $faq_query->post_count;
// 计算每个 div 中的文章数量
$posts_per_div = ceil($total_posts / 2); // 向上取整
// 初始化文章索引
$current_post = 0;
// 循环输出文章,并进行分组
while ($faq_query->have_posts()) {
// 如果是新的分组的开始,输出新的 <div> 标签
if ($current_post % $posts_per_div == 0) {
if ($current_post > 0) {
echo '</div>'; // 关闭前一个 div
}
echo '<div class="post-group">'; // 开始新的 div
}
$faq_query->the_post();
// 输出文章内容
?>
<div class="post-accordion">
<div class="accordion-title">
<h2><?php the_title();?></h2>
<i class="ri-arrow-down-s-line"></i>
</div>
<div class="accordion-desc">
<?php the_content();?>
</div>
</div>
<?php
$current_post++;
}
// 结束最后一个 <div> 标签
echo '</div>';
} else {
// 不使用 div 包裹,直接输出文章内容
while ($faq_query->have_posts()) {
$faq_query->the_post();
?>
<div class="post-accordion">
<div class="accordion-title">
<h2><?php the_title();?></h2>
<i class="ri-arrow-down-s-line"></i>
</div>
<div class="accordion-desc">
<?php the_content();?>
</div>
</div>
<?php
}
}
}
}
?>
</div>
</div>
</div>
<?php }
//echo wpjam_print_r( $module_setting );
//echo wpjam_print_r( $module_content );
//echo wpjam_print_r( $module_style );