使用ACF与组嵌套的中继器

时间:2018-07-09 10:27:22

标签: php wordpress advanced-custom-fields custom-fields

我在显示ACF字段时遇到麻烦,我使用ACF的专业版,这是我在ACF中所做的工作的示意图

import ast

df['Match'] = df['Match'].astype(str)

df['Match'] = df['Match'].apply(ast.literal_eval)
df['new2'] = df['Match'].str[0]
print (df)

   ID                                     Match           new2
0   1                           [(word1, , , )]  (word1, , , )
1   2                 [(word2, , , ), (word1,)]  (word2, , , )
2   3  [(word2, , , ), (word1,), (word3, , , )]  (word2, , , )

我希望它像这样显示

series (repeater)
- event_group (group)
-- series_year (text)
-- series_year_details (repeater)
--- series_event (text)
--- series_date (date)
--- series_view (file)

箭头(>)是文件的链接。

这是我当前的代码

**2018**
event name 1 - July 24, 2018 >
event name 2 - July 28, 2018 >
event name 3 - July 30, 2018 >

**2017**
event name 4 - June 24, 2018 >
event name 5 - June 28, 2018 >
event name 6 - June 30, 2018 >

1 个答案:

答案 0 :(得分:0)

请尝试这个,让我知道

<?php
    if( have_rows('series') ): 
      while( have_rows('series') ): the_row(); ?>
        <div>
            <h3><?php the_sub_field('series_year'); ?></h3>
            <?php if( have_rows('series_year_details') ): ?>
                <ul>
                    <?php while( have_rows('series_year_details') ): the_row(); ?>
                    <li>
                    event name : <?php echo the_sub_field('event'); ?> -  <?php the_sub_field('date'); ?> <a href="<?php the_sub_field('view'); ?>"> > </a><br>
                    </li>
                   <?php endwhile; ?>
                </ul>
            <?php endif; ?>
        </div>  

    <?php endwhile;
    endif; ?>