0
使用高级自定义字段创建WP页面。 我有一个由2个字段的FIELDGROUP:在变量中存储ACF字段
标题 - 文本字段 Columnsection - 其中包含2所见即所得的字段名为left_col和right_col一个repeaterfield。
所以结果可能看起来像:
Cars (title)
image of a volvo (left_col) text about a volvo(right_col)
image of a BMW (left_col) text about a BMW(right_col)
image of a Fiat (left_col) text about a Fiat(right_col)
好了,所以我试图在我的模板做的是创建一个将容纳所有值三个变量:
$titles = all Titles
$left_col = all left_cols
$right_col = all right_cols
的FIELDGROUP被称为repeater
所以我可以做:
<?php
while(have_rows('repeater')): the_row();
$title = get_sub_field('main_title');
$rows = get_sub_field('column_section');
$left = $rows['left_column'];
$right = $rows['right_column'];
echo $title; // Title echoes out
echo $left; // nothing (expecting array of left_cols 'related to the title')
echo $right; //nothing (expecting array of right_cols 'related to the title')
?>
的IM理由试图做T他的意思是我希望将right_columns和left_columns分开,以便在模板中的不同位置使用它们。
帮助赞赏。谢谢!
看一看的文档关于嵌套中继器:https://www.advancedcustomfields.com/resources/working-with-nested-repeaters/ – Jrod