Wordpress the_content() -自定义img模板


Wordpress the_content() - customizing img template

我正在做一个博客,它有特定的html5结构的img:

<figure>
<img />
<figcaption></figcaption>
</figure>

是否有一种方法来定制,如何the_content()处理img渲染,添加我自己的模板img具体(加上添加the_post_thumbnail_caption()模板)?

或者有一种方法可以为所见即所得制作自己的模板。我之所以这样问,是因为我想允许用户应用三种可能的img显示之一,这些显示绑定到特定的图形元素类(例如)

Thanks in advance

您可以使用get_the_content()然后使用preg_match查找img标记并用您自己的代码替换查看如何在这里用preg_match替换img https://stackoverflow.com/a/1107203/1287608

和get_the_content()函数http://codex.wordpress.org/Function_Reference/get_the_content