ACF 中继器,内置灵活内容
ACF Repeater w/ Flexible Content Inside
我正在使用高级自定义字段。我已经直接从他们那里拿到了票,但需要一段时间。我需要立即解决这个问题。
尝试为英雄滑块重复灵活的内容,用户可以在其中添加视频嵌入或图像。如何正确回显循环中的每一部分? Wordpress 中输入的内容没有出现。容器有回声,只是没有内容。
<?php
if (have_rows('add_resorts_hero_image_slide', 'option')) {
while (have_rows('add_resorts_hero_image_slide', 'option')) {
the_row();
$herovideo = the_sub_field('add_resorts_hero_slider_video');
$heroimage = the_sub_field('add_resorts_hero_slider_image');
$heroimgsize = 'hero-image';
$heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
$heroimg_url = $heroimg_array[0];
if (have_rows('choose_resorts_hero_slider_content')) {
while (have_rows('choose_resorts_hero_slider_content')) {
the_row();
echo '<li class="orbit-slide">';
if( get_row_layout() == 'resorts_slider_video' )
echo $herovideo;
elseif( get_row_layout() == 'resorts_slider_video')
echo '<img src="'.$heroimg_url.'" />';
echo '</li>';
}
}
}
}
只需重新发布您代码的相关部分:
if( get_row_layout() == 'resorts_slider_video' ){
//Display iFrame Video (this assumes that your field is a URL field.)
echo '<iframe src="'.get_sub_field('IFRAME URL FIELD NAME GOES HERE').'"></iframe>';
}elseif( get_row_layout() == 'resorts_slider_video'){
//Display Image (this assumes that your field is an image field, being saved as an Image Object, and you want to output a custom image size)
$myImage = get_sub_field('IMAGE FIELD NAME GOES HERE');
echo '<img src="'.$myImage['sizes']['CUSTOM IMAGE SIZE NAME'].'" alt="'.$myImage['alt'].'" />';
}
终于明白我需要什么了。希望这个答案能帮助其他人!
<!--ORBIT SLIDE-->
<?php
if (have_rows('add_resorts_hero_image_slide', 'option')) {
while (have_rows('add_resorts_hero_image_slide', 'option')) {
the_row();
if (have_rows('choose_resorts_hero_slider_content')) {
while (have_rows('choose_resorts_hero_slider_content')) {
the_row();
$herovideo = get_sub_field('add_resorts_hero_slider_video');
$heroimage = get_sub_field('add_resorts_hero_slider_image');
$heroimgsize = 'hero-image';
$heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
$heroimg_url = $heroimg_array[0];
if( get_row_layout() == 'resorts_slider_video' ) {
echo '<li class="video orbit-slide">';
echo '<img class="background" src="http://localhost.com/vail/tier2-hero-placeholder.jpg" />';
echo '<div class="container">
<div class="watermark"></div>
<iframe id="heroorbitslider-video"
src="'. $herovideo .'"
width="100%"
frameborder="0"
scrolling="no"
allowFullscreen="true"
allowFullScreen="true"
webkitAllowFullScreen="true"
mozAllowFullScreen="true">
</iframe>
</div>';
echo '</li>';
}
elseif( get_row_layout() == 'resorts_slider_image') {
echo '<li class="orbit-slide">';
echo '<img class="background "src="'. $heroimg_url .'" />';
echo '</li>';
}
}
}
}
}
?>
<!--END ORBIT SLIDE-->
我正在使用高级自定义字段。我已经直接从他们那里拿到了票,但需要一段时间。我需要立即解决这个问题。
尝试为英雄滑块重复灵活的内容,用户可以在其中添加视频嵌入或图像。如何正确回显循环中的每一部分? Wordpress 中输入的内容没有出现。容器有回声,只是没有内容。
<?php
if (have_rows('add_resorts_hero_image_slide', 'option')) {
while (have_rows('add_resorts_hero_image_slide', 'option')) {
the_row();
$herovideo = the_sub_field('add_resorts_hero_slider_video');
$heroimage = the_sub_field('add_resorts_hero_slider_image');
$heroimgsize = 'hero-image';
$heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
$heroimg_url = $heroimg_array[0];
if (have_rows('choose_resorts_hero_slider_content')) {
while (have_rows('choose_resorts_hero_slider_content')) {
the_row();
echo '<li class="orbit-slide">';
if( get_row_layout() == 'resorts_slider_video' )
echo $herovideo;
elseif( get_row_layout() == 'resorts_slider_video')
echo '<img src="'.$heroimg_url.'" />';
echo '</li>';
}
}
}
}
只需重新发布您代码的相关部分:
if( get_row_layout() == 'resorts_slider_video' ){
//Display iFrame Video (this assumes that your field is a URL field.)
echo '<iframe src="'.get_sub_field('IFRAME URL FIELD NAME GOES HERE').'"></iframe>';
}elseif( get_row_layout() == 'resorts_slider_video'){
//Display Image (this assumes that your field is an image field, being saved as an Image Object, and you want to output a custom image size)
$myImage = get_sub_field('IMAGE FIELD NAME GOES HERE');
echo '<img src="'.$myImage['sizes']['CUSTOM IMAGE SIZE NAME'].'" alt="'.$myImage['alt'].'" />';
}
终于明白我需要什么了。希望这个答案能帮助其他人!
<!--ORBIT SLIDE-->
<?php
if (have_rows('add_resorts_hero_image_slide', 'option')) {
while (have_rows('add_resorts_hero_image_slide', 'option')) {
the_row();
if (have_rows('choose_resorts_hero_slider_content')) {
while (have_rows('choose_resorts_hero_slider_content')) {
the_row();
$herovideo = get_sub_field('add_resorts_hero_slider_video');
$heroimage = get_sub_field('add_resorts_hero_slider_image');
$heroimgsize = 'hero-image';
$heroimg_array = wp_get_attachment_image_src($heroimage, $heroimgsize);
$heroimg_url = $heroimg_array[0];
if( get_row_layout() == 'resorts_slider_video' ) {
echo '<li class="video orbit-slide">';
echo '<img class="background" src="http://localhost.com/vail/tier2-hero-placeholder.jpg" />';
echo '<div class="container">
<div class="watermark"></div>
<iframe id="heroorbitslider-video"
src="'. $herovideo .'"
width="100%"
frameborder="0"
scrolling="no"
allowFullscreen="true"
allowFullScreen="true"
webkitAllowFullScreen="true"
mozAllowFullScreen="true">
</iframe>
</div>';
echo '</li>';
}
elseif( get_row_layout() == 'resorts_slider_image') {
echo '<li class="orbit-slide">';
echo '<img class="background "src="'. $heroimg_url .'" />';
echo '</li>';
}
}
}
}
}
?>
<!--END ORBIT SLIDE-->