Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在html链接中包装输出_Php_Wordpress_Iframe - Fatal编程技术网

Php 在html链接中包装输出

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

您好,我有一段代码,用于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(
'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>';