duanan1228 2017-08-01 08:07
浏览 21

排序生成单个html列表的两个不同的php循环

Using ACF plugin in Wordpress I created a checkbox field which return the ID of each selected values. I then echo the image of each selected values through wp_get_attachment_image.

I also created a text field for dynamic input of text like this which then becomes this

Here is a piece of my code :

<?php $values_caract = get_field('picto_statique_Caract');
                            if( !empty($values_caract) ): ?>
                                <div class="icon-list">
                                    <ul>
                                        <?php foreach($values_caract as $value_caract): ?>
                                            <li><?php echo wp_get_attachment_image( $value_caract, 'full' );?></li>
                                        <?php endforeach; ?>
                                        <?php if( get_field('ip3x') ): ?>
                                            <li>
                                                <div class="picto">
                                                    <?php echo wp_get_attachment_image( 3145, 'full' );?>
                                                    <div class="text-ip3x">
                                                        <?php the_field('ip3x'); ?>
                                                    </div>
                                                </div>
                                            </li>
                                        <?php endif; ?>
                                        <?php if( get_field('ip4x') ): ?>
                                            <li>
                                                <div class="picto">
                                                    <?php echo wp_get_attachment_image( 3158, 'full' );?>
                                                    <div class="text-ip3x">
                                                        <?php the_field('ip4x'); ?>
                                                    </div>
                                                </div>
                                            </li>
                                        <?php endif; ?>
     </ul>
     </div>
                            <?php endif; ?>

My issue is that this generate a list of images which I cannot sort because the foreach loop for static images and the if condition for dynamic images are two different loops. Any idea how to do this ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥170 如图所示配置eNSP
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改
    • ¥20 wireshark抓不到vlan
    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥15 键盘指令混乱情况下的启动盘系统重装