function fetchSliderImages() {
//Empty array for holding your slider images, assuming there's more than one
$sliderImages = array();
//Check to see if the slider even has rows
if( have_rows('slajder') ):
//Loop through all the rows of your slider
while( have_rows('slajder') ) : the_row();
//Assuming this is coming back as a URL (can be adjusted within ACF)
$imageRepeaterValue = get_sub_field('obraz_slajdera');
//Check to see that we actually got something back that isn't blank
if($imageRepeaterValue != '') {
array_push($sliderImages, $imageRepeaterValue);
}
endwhile;
endif;
return $sliderImages;
}
1条答案
按热度按时间kwvwclae1#
您可能需要阅读ACF开发人员文档,您的代码是零碎的,并且**get_field()**函数没有被正确使用。无论如何,我会尽我所能来解释你的解决方案应该指向什么。你首先需要遍历你的repeater字段,检查repeater字段中是否有“行,”获取你的值,然后对相应的图像执行任何需要的操作。
因此,从技术上讲,您的函数应该类似于:
然后,您可以使用此函数返回滑块图像的URL数组。
参考以下内容:https://www.advancedcustomfields.com/resources/repeater/