【发布时间】:2017-05-22 12:09:29
【问题描述】:
我正在尝试在我的 wordpress 网站上显示 2 个不同的值:skuar.com 应该是,点击任何缩略图(中心标志)后
如果('music')中有字段值:显示
否则,在 ('image') 字段中显示值
其实不行,代码好不好?
<?php
$music = get_field('music');
$image = get_field('image');
if ($music!=''){ ?>
<iframe width="600" height="166" scrolling="no" class="lightbox" class="frame" id="featherlight" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php the_field('music'); ?>&color=1b1e25&theme_color=1b1e25&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>
<?php } else { ?>
<img src="<?php $image ?>" />
<?php endif; ?>
<?php } ?>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('post-thumbnails');
}
?>
谢谢
【问题讨论】:
标签: php wordpress if-statement advanced-custom-fields custom-fields