HEX
Server: nginx/1.16.1
System: Linux VM-0-14-centos 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User: www (1000)
PHP: 8.3.31
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
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 );