Php 更改媒体文件的输出标记

Php 更改媒体文件的输出标记,php,wordpress,Php,Wordpress,我正在为一个朋友创建一个wordpress主题,并尝试在使用文章上的媒体按钮插入的图像前后添加一些标记 这是我到目前为止得到的,但它给了我一个错误。任何建议或帮助都将不胜感激 add_filter ('the_content', 'wpse264886_content_insert_html', 10, 1); function wpse264886_content_insert_html ($content) { $html1 = 'before ... '; $html2 =

我正在为一个朋友创建一个wordpress主题,并尝试在使用文章上的媒体按钮插入的图像前后添加一些标记

这是我到目前为止得到的,但它给了我一个错误。任何建议或帮助都将不胜感激

add_filter ('the_content', 'wpse264886_content_insert_html', 10, 1);
function wpse264886_content_insert_html ($content) {
  $html1 = 'before ... ';
  $html2    =  'after ...';
  $content = preg_replace('/(<a.*?)><(img.*?)/', '$1>' . $html1 . '<$2>' . $html2, $content);
  return $content;
  }
add_filter('the_content','wpse264886_content_insert_html',10,1);
函数wpse264886\u content\u insert\u html($content){
$html1=‘在……之前’;
$html2='在…之后';
$content=preg_replace('/('.$html1'.$html2,$content);
返回$content;
}
谢谢


Ponte

欢迎来到SO。为了提高您获得答案的机会,我建议您a)发布错误消息,b)使用语言(PHP?)标记您的问题。嗨,Johnny!非常感谢您的欢迎和建议。我现在就要开始了=)看看页面,我只得到了在页面上吐出的http//imagelocation。没有那么多的错误我不太会PHP,也没有Wordpress,所以我帮不了你。这就是为什么标记问题很重要。它吸引了能回答问题的人。