嵌套转发器字段ACF - 显示来自字段1的内容

时间:2016-07-21 12:55:04

标签: wordpress advanced-custom-fields

我有一个嵌套的转发器字段。

嵌套部分是一个模态窗口,当打开时会扩展第二个转发器字段。但是当所有内容都填写完毕后,模态窗口会显示循环中第一项的信息。

这是它应该如何工作: http://pagedev.co.uk/hoppings/product-sector.php#

这是我的代码:

    <div class="container">

        <?php while( have_rows('product_sections') ): the_row(); ?>


        <div class="sector-heading">
            <img src="<?php the_sub_field('section_logo'); ?>">
            <div><?php the_sub_field('section_intro'); ?></div>
        </div>


            <?php if( have_rows('products') ): ?>


                <div class="grid-wrapper">


                    <?php while( have_rows('products') ): the_row(); ?>


                        <!--Start Single Product-->
                        <div class="grid-item">

                            <div class="image-hovers">
                                <img src="<?php the_sub_field('thumbnail'); ?>">
                                <a class="js-open-modal" href="#" data-modal-id="popup"><div class="product-hover"></div></a>
                            </div>

                            <div class="grid-title">
                                <h2><?php the_sub_field('product_name'); ?></h2>
                            </div>

                        </div>


                                <!--Start Single Product Modal-->
                                <div id="popup" class="modal-box"> 

                                    <a href="#" class="js-modal-close close">×</a>

                                    <div class="modal-wrap">

                                        <div class="modal-img">
                                            <img src="<?php the_sub_field('thumbnail'); ?>">
                                        </div>

                                        <div class="modal-content">
                                            <h2><?php the_sub_field('product_name'); ?></h2>
                                            <p><strong><?php the_sub_field('product_size'); ?></strong></p>
                                            <hr>
                                            <?php the_sub_field('product_description'); ?>
                                            <a href="<?php the_sub_field('product_description'); ?>"><div class="modal-stockist">Find a Stockist</div></a>
                                            <a href="<?php the_sub_field('literature_link'); ?>"><div class="modal-literature">Literature</div></a>
                                        </div>

                                    </div>

                                </div>
                                <!--Close Single Product Modal-->



                        <?php endwhile; // end of the loop. ?>

                </div>
                <!--End Grid Wrapper-->

            <?php endif; ?>
            <!-- Close product repeater field -->


        <?php endwhile; // end of the loop. ?>


    </div>
    <!--End Container-->

任何帮助都会很棒!

1 个答案:

答案 0 :(得分:0)

我明白了。这么简单!

我的模态窗口需要每个产品的唯一ID!

全部解决了:))

相关问题