所以問題在這裏。我有兩個PHP文件(one.php和two.php)。第一個循環從0開始並停在77.在PHP循環中添加中斷後,您如何繼續操作?
下一個循環從行78開始,停在300.這部分工作。出於某種原因,來自two.php的所有行都不顯示。我認爲one.php的循環阻止了two.php完全運行。我在WordPress中使用高級自定義字段(ACF)。
/*** One.php ***/
<?php
if(have_rows('repeat_field')):
$i = 0;
// loop through the rows of data
while (have_rows('repeat_field')) : the_row();
$i++;
continue;
if (!empty(get_sub_field('feature_image_post')))
{
the_sub_field('feature_article_link');
the_sub_field('feature_image_post');
the_sub_field('feature_title');
}
if($i > 77)
{
break;
}
endwhile;
else :
// no rows found
endif;
?>
/*** Two.php ***/
<?php
if(have_rows('repeat_field')):
$i = 0;
// loop through the rows of data
while (have_rows('repeat_field')) : the_row();
$i++;
if($i<79)
continue;
if (!empty(get_sub_field('feature_image_post')))
{
the_sub_field('feature_article_link');
the_sub_field('feature_image_post');
the_sub_field('feature_title');
}
if($i > 100)
{
break;
}
endwhile;
else :
// no rows found
endif;
?>
兩個文件都包含在一個PHP模板文件:
也許你不需要'continue' – Sysix
@ Sysix好了,你有沒有替代方案或建議? – Mariton
告訴我應該輸出哪些行?使用'$ i'變量作爲計數器;) – Sysix