【发布时间】:2014-02-14 11:35:02
【问题描述】:
基本上我正在寻找最简单的代码来解决这个问题。我有一个在为 iframe src 填充自定义字段时填充的 iframe。
基本上,如果未填写自定义字段,我希望 iframe 代码完全消失。
这样我就可以在 page.php 中弹出此代码,并且 iframe 仅显示自定义字段是否已填充。
<?php
$iframe_src = get_post_meta( get_the_ID(), 'iframe_src', true );
$iframe_height = get_post_meta( get_the_ID(), 'iframe_height', true );
$height = ( $iframe_height == "" || !$iframe_height ) ? 2650 : $iframe_height;
?>
<iframe SRC="<?php echo $iframe_src; ?>" WIDTH="100%" HEIGHT="<?php echo $height; ?>" frameborder="0" scrolling="no" name="content"></iframe>
【问题讨论】:
-
if ($iframe_src != '') { ... }? -
对不起,我比较新,我把这个放在哪里?
标签: javascript php iframe if-statement custom-fields