将图像添加到内容

我正在使用此代码在WP博客文章的末尾添加标签:


    function tags_after_single_post_content($content) {

  $posttags = get_the_tags();

  if ($posttags) {

    $array = [];

    foreach($posttags as $tag) {

      $array[] = '<a href="/tag/' . $tag->slug . '/">' . $tag->name . '</a>';

    }

    $content .= 'Tags: ' . implode(', ', $array) . '<br>';

  }


  return $content;

}

add_filter( 'the_content', 'tags_after_single_post_content' );

但我想插入一个图像而不是“标签:”这个词,这可能吗?


墨色风雨
浏览 66回答 1
1回答

慕桂英546537

尝试以这种方式更改行:$content&nbsp;.=&nbsp;'<img&nbsp;src="path.jpg">&nbsp;'&nbsp;.&nbsp;implode(',&nbsp;',&nbsp;$array)&nbsp;.&nbsp;'<br>';
打开App,查看更多内容
随时随地看视频慕课网APP