我有以下代码,通过html嵌入代码显示当前的YouTube视频。
<?php
if ( function_exists( 'wpmudev_ppw_html' ) ) {
$html = '<iframe width="560" height="315" src="https://www.youtube.com/embed/-uiN9z5tqhg?wmode=transparent&" frameborder="0" allowfullscreen></iframe>'; // html code to be protected (required)
$id = 1; // An optional unique id if you are using the function more than once on a single page
$description = 'video'; // Optional description of the protected content
$price = '1.50'; // Optional price for a single view. If not set, price set in the post will be applied. If that is not set either, Unit Price in the Global Settings will be used.
echo wpmudev_ppw_html( $html, $id, $description, $price );
}
?>
我想删除YouTube iFrame并让它显示以下代码。
<img class="img-responsive img-thumbnail" src="<?php the_field('macro_map'); ?>" />
然而,$ html =行中的PHP代码在完成时会导致语法错误......
$html = '<img class="img-responsive img-thumbnail" src="<?php the_field('macro_map'); ?>" />';
首先,它是否有可能发挥作用。如果是这样,我做错了什么?
答案 0 :(得分:2)
<?php ?>
标记内无法<?php ?>
。您将需要删除嵌套标记并使用.
来连接字符串并返回函数。
$html = '<img class="img-responsive img-thumbnail" src="' . the_field('macro_map') . '" />';