【发布时间】:2018-12-29 23:21:07
【问题描述】:
我在我的网站上使用 ACF,并尝试设置一个 PHP 变量,它是一个包含 ACF 字段的 iframe。
我不知道为什么这不起作用,因为我可以回显变量并显示它,但它会吐出 src(unknown) 否则?
// Get spotify and set up tab
if (have_rows('roster_media')):
// loop through the rows of data
while (have_rows('roster_media')): the_row();
$spotify_uri = get_sub_field('rm_sp_link');
echo $spotify_uri;
$url = $spotify_uri;
echo $url;
endwhile;
else:
// no rows found
endif;
$rm_sp = '<iframe src="'.$url.'" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>';
然后在我通过以下方式调用的页面中:
<?php
$count = 0;
foreach ($embed_links as $e) {
if ($count==0) {
$rm_act = " active show";
} else {
$rm_act = "";
}
$content;
if ($e['embed_platform']['value'] === "rm_sp") {
$content ='<div class="rm-video">'.$rm_sp.'</div>';
} else if ($e['embed_platform']['value']==="rm_vid") {
$content = '<div class="rm-video">'.$rm_vid.'</div>';
}
echo '<div class="tab-pane'.$rm_act.'" id="'.$e['embed_platform']['value'].'" role="tabpanel">'.$content.'</div>';
$count++;
}
?>
【问题讨论】:
-
对于任何想知道的人,我目前正在使用 jQuery(我认为这不是最好的方法,但它对我有用)。
标签: php html iframe wordpress-theming advanced-custom-fields