我正在使用高级自定义字段。我直接拿到了他们的票,但需要一段时间。我需要立即解决这个问题。
尝试为英雄滑块重复灵活内容,用户可以在其中添加视频嵌入或图像。如何正确回显循环中的每个部分? 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>';
}
}
}
}
答案 0 :(得分:0)
只需重新发布代码的相关部分:
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'].'" />';
}
答案 1 :(得分:0)
终于找到了我需要的东西。希望这个答案可以帮助其他人!
<!--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-->