我有一个关系字段,可将帖子/内容传递到灵活的内容字段。现在,我有了一个作为中继器的块,运行时,即使添加更多,它也只会返回一行。我要去哪里错了?
<?php
global $post; // Querying outside the loop
$cta_block_item = get_sub_field( 'relationship_field', $post->ID );
if ( $cta_block_item ):
foreach ( $posts as $post ):
setup_postdata ( $post );
if (have_rows('page_builder')): // Get the rows of the Flexible content field of my target
while (have_rows('page_builder', $post->ID)):
the_row();
if (get_row_layout() == 'cta_grid') {
$cta_grid_select = get_sub_field('cta_grid_select'); // get the custom field I want to get
if ( have_rows( 'row') ) :
while ( have_rows( 'row', $post->ID ) ) : the_row();
if ( $cta_grid_select ):
foreach ( $cta_grid_select as $post ):
setup_postdata ( $post );
// Expected: I should see all rows of my repeaters content
// Current Result: Returns only one row from the repeater
endforeach;
wp_reset_postdata();
endif;
endwhile;
else :
// no rows found
endif;
}
endwhile;
else:
// no layouts found
endif;
endforeach;
wp_reset_postdata();
endif;
?>
预期:我应该看到中继器内容的所有行
实际结果:仅从中继器返回一行