【问题标题】:Wrapping output in html link在 html 链接中包装输出
【发布时间】:2020-04-18 18:41:52
【问题描述】:

您好,我将这段代码用于 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;
?>

我想包装输出 echo $iframe;带有指向下面帖子的链接,但不确定如何格式化。

<a rel="external" href="<? the_permalink()?>">  </a>

【问题讨论】:

    标签: php wordpress iframe


    【解决方案1】:

    这是你要找的吗?

    *如果你在循环中它应该工作

    // Display customized HTML.
    echo '<a rel="external" href="'.the_permalink().'">'.$iframe.'</a>';
    

    【讨论】:

      猜你喜欢
      • 2017-07-16
      • 1970-01-01
      • 1970-01-01
      • 2015-03-16
      • 2018-07-29
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 2014-02-26
      相关资源
      最近更新 更多