我有一个 wordpress 网站和来自 the_content()
的图像函数有<img>
标签,但是对于 AMP 页面,它们应该这样写:<amp-img>
。在 WP 中这样做的正确方法是什么?
最佳答案
试试这个:
add_filter('the_content', 'change_img', 99);
function change_img( $content )
{
return str_replace('<img', '<amp-img', $content);
}
关于php - 将 img 标签转换为 amp-img 的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50798377/