使用ACF,可以选择在转发器字段中添加图库。但是,我的问题是,我如何编写可以展示此画廊的PHP。
我试图找到类似的问题,但哪些解决方案对我不起作用。我还尝试查找YouTube视频并搜索ACF文档网站。支持中继器中画廊的组合的代码对我似乎不起作用。
这是转发器的标准ACF PHP格式:
itemRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView,dx: Int,dy: Int) {
super.onScrolled(recyclerView,dx,dy)
log("onScrolled")
val layoutManager = itemRecyclerView.layoutManager
if (layoutManager is LinearLayoutManager) {
log("First visible Item: " + layoutManager.findFirstVisibleItemPosition())
log("First complete visible Item: " + layoutManager.findFirstCompletelyVisibleItemPosition())
log("Last visible Item: " + layoutManager.findLastVisibleItemPosition())
log("Last complete visible Item: " + layoutManager.findLastCompletelyVisibleItemPosition())
}
}
这是画廊的标准ACF PHP格式:
<?php
// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
// display a sub field value
the_sub_field('sub_field_name');
endwhile;
else :
// no rows found
endif;
?>
我希望我能以某种方式将两者结合起来以获得预期的结果。我的PHP知识不是很好。因此欢迎所有帮助。