Php 在html链接中包装输出
您好,我有一段代码,用于ACF嵌入字段:Php 在html链接中包装输出,php,wordpress,iframe,Php,Wordpress,Iframe,您好,我有一段代码,用于ACF嵌入字段: <?php // Load value. $iframe = get_field('video'); // Use preg_match to find iframe src. preg_match('/src="(.+?)"/', $iframe, $matches); $src = $matches[1]; // Add extra parameters to src and replcae HTML. $params = array( 'ti
<?php
// Load value.
$iframe = get_field('video');
// Use preg_match to find iframe src.
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];
// Add extra parameters to src and replcae HTML.
$params = array(
'title' => 0,
'byline' => 0,
'portrait' => 0,
'muted' => 1,
'autoplay' => 1,
'autopause' => 1,
'controls' => 0,
'loop' => 1,
'background' => 0,
);
$new_src = add_query_arg($params, $src);
$iframe = str_replace($src, $new_src, $iframe);
// Add extra attributes to iframe HTML.
$attributes = 'frameborder="0"';
$iframe = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $iframe);
// Display customized HTML.
echo $iframe;
?>
这就是你要找的吗 *如果你在循环中,它应该工作
// Display customized HTML.
echo '<a rel="external" href="'.the_permalink().'">'.$iframe.'</a>';
//显示自定义HTML。
回声';
// Display customized HTML.
echo '<a rel="external" href="'.the_permalink().'">'.$iframe.'</a>';